scopeManager = $scopeManager; $this->wrapped = $wrapped; $this->finishSpanOnClose = $finishSpanOnClose; $this->toRestore = $scopeManager->getActive(); } /** * {@inheritdoc} */ public function close(): void { if ($this->scopeManager->getActive() !== $this) { // This shouldn't happen if users call methods in expected order return; } if ($this->finishSpanOnClose) { $this->wrapped->finish(); } $this->scopeManager->setActive($this->toRestore); } /** * {@inheritdoc} */ public function getSpan(): OTSpan { return $this->wrapped; } }