diff --git a/src/DrupalInstrumentation.php b/src/DrupalInstrumentation.php index 163739d..7b0f3d9 100644 --- a/src/DrupalInstrumentation.php +++ b/src/DrupalInstrumentation.php @@ -109,109 +109,5 @@ public static function register(): void $span->end(); } ); - - hook( - HttpKernelInterface::class, - 'handle', - pre: static function ( - HttpKernelInterface $kernel, - array $params, - string $class, - string $function, - ?string $filename, - ?int $lineno, - ) use ($instrumentation): array { - $messageClass = \get_class($kernel); - - /** @psalm-suppress ArgumentTypeCoercion */ - $builder = $instrumentation - ->tracer() - ->spanBuilder($messageClass) - ->setSpanKind(SpanKind::KIND_INTERNAL) - ->setAttribute(TraceAttributes::CODE_FUNCTION, $function) - ->setAttribute(TraceAttributes::CODE_NAMESPACE, $class) - ->setAttribute(TraceAttributes::CODE_FILEPATH, $filename) - ->setAttribute(TraceAttributes::CODE_LINENO, $lineno); - - $parent = Context::getCurrent(); - $span = $builder - ->setParent($parent) - ->startSpan(); - - $context = $span->storeInContext($parent); - Context::storage()->attach($context); - - return $params; - }, - post: static function ( - HttpKernelInterface $kernel, - array $params, - ?Response $response, - ?\Throwable $exception - ): void { - $scope = Context::storage()->scope(); - if (null === $scope) { - return; - } - - $scope->detach(); - - $span = Span::fromContext($scope->context()); - - $span->end(); - } - ); - - hook( - EventSubscriberInterface::class, - 'handle', - pre: static function ( - HttpKernelInterface $kernel, - array $params, - string $class, - string $function, - ?string $filename, - ?int $lineno, - ) use ($instrumentation): array { - $messageClass = \get_class($kernel); - - /** @psalm-suppress ArgumentTypeCoercion */ - $builder = $instrumentation - ->tracer() - ->spanBuilder($messageClass) - ->setSpanKind(SpanKind::KIND_INTERNAL) - ->setAttribute(TraceAttributes::CODE_FUNCTION, $function) - ->setAttribute(TraceAttributes::CODE_NAMESPACE, $class) - ->setAttribute(TraceAttributes::CODE_FILEPATH, $filename) - ->setAttribute(TraceAttributes::CODE_LINENO, $lineno); - - $parent = Context::getCurrent(); - $span = $builder - ->setParent($parent) - ->startSpan(); - - $context = $span->storeInContext($parent); - Context::storage()->attach($context); - - return $params; - }, - post: static function ( - HttpKernelInterface $kernel, - array $params, - ?Response $response, - ?\Throwable $exception - ): void { - $scope = Context::storage()->scope(); - if (null === $scope) { - return; - } - - $scope->detach(); - - $span = Span::fromContext($scope->context()); - - $span->end(); - } - ); } }