diff --git a/src/Instrumentation/Symfony/src/HttpClientInstrumentation.php b/src/Instrumentation/Symfony/src/HttpClientInstrumentation.php index 5e0c2b0e..4e2225b7 100644 --- a/src/Instrumentation/Symfony/src/HttpClientInstrumentation.php +++ b/src/Instrumentation/Symfony/src/HttpClientInstrumentation.php @@ -36,7 +36,7 @@ public static function register(): void /** @psalm-suppress ArgumentTypeCoercion */ $builder = $instrumentation ->tracer() - ->spanBuilder(\sprintf('HTTP %s', $params[0])) + ->spanBuilder(\sprintf('HTTP %s %s', $params[0], parse_url($params[1], PHP_URL_HOST))) ->setSpanKind(SpanKind::KIND_CLIENT) ->setAttribute(TraceAttributes::HTTP_URL, (string) $params[1]) ->setAttribute(TraceAttributes::HTTP_METHOD, $params[0]) diff --git a/src/Instrumentation/Symfony/src/SymfonyInstrumentation.php b/src/Instrumentation/Symfony/src/SymfonyInstrumentation.php index 5074529a..0668ddf6 100644 --- a/src/Instrumentation/Symfony/src/SymfonyInstrumentation.php +++ b/src/Instrumentation/Symfony/src/SymfonyInstrumentation.php @@ -11,6 +11,7 @@ use OpenTelemetry\API\Trace\SpanKind; use OpenTelemetry\API\Trace\StatusCode; use OpenTelemetry\Context\Context; +use Symfony\Component\HttpKernel\HttpKernelInterface; use function OpenTelemetry\Instrumentation\hook; use OpenTelemetry\SemConv\TraceAttributes; use Symfony\Component\HttpFoundation\Request; @@ -40,7 +41,7 @@ public static function register(): void /** @psalm-suppress ArgumentTypeCoercion */ $builder = $instrumentation ->tracer() - ->spanBuilder(\sprintf('HTTP %s', $request?->getMethod() ?? 'unknown')) + ->spanBuilder(\sprintf('HTTP %s', $request?->getMethod() ?? 'unknown method')) ->setSpanKind(SpanKind::KIND_SERVER) ->setAttribute(TraceAttributes::CODE_FUNCTION, $function) ->setAttribute(TraceAttributes::CODE_NAMESPACE, $class) @@ -79,6 +80,14 @@ public static function register(): void $span = Span::fromContext($scope->context()); $request = ($params[0] instanceof Request) ? $params[0] : null; + if ($params[1] === HttpKernelInterface::MAIN_REQUEST) { + $span->updateName(\sprintf( + 'HTTP %s %s', + $request?->getMethod() ?? 'unknown method', + $request?->attributes->get('_route', 'unknown route') + )); + } + if (null !== $request) { $routeName = $request->attributes->get('_route', '');