From cdd7ad020e165fe680703b6d3319b908b682fb7a Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Fri, 20 Oct 2023 17:12:29 +0300 Subject: jaeger-client -> opentelemetry --- vendor/open-telemetry/context/ContextStorage.php | 57 ++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 vendor/open-telemetry/context/ContextStorage.php (limited to 'vendor/open-telemetry/context/ContextStorage.php') diff --git a/vendor/open-telemetry/context/ContextStorage.php b/vendor/open-telemetry/context/ContextStorage.php new file mode 100644 index 000000000..e82d3d161 --- /dev/null +++ b/vendor/open-telemetry/context/ContextStorage.php @@ -0,0 +1,57 @@ + */ + private array $forks = []; + + public function __construct() + { + $this->current = $this->main = new ContextStorageHead($this); + } + + public function fork($id): void + { + $this->forks[$id] = clone $this->current; + } + + public function switch($id): void + { + $this->current = $this->forks[$id] ?? $this->main; + } + + public function destroy($id): void + { + unset($this->forks[$id]); + } + + public function scope(): ?ContextStorageScopeInterface + { + return ($this->current->node->head ?? null) === $this->current + ? $this->current->node + : null; + } + + public function current(): ContextInterface + { + return $this->current->node->context ?? Context::getRoot(); + } + + public function attach(ContextInterface $context): ContextStorageScopeInterface + { + return $this->current->node = new ContextStorageNode($context, $this->current, $this->current->node); + } + + private function __clone() + { + } +} -- cgit v1.2.3