Skip to content

[opentelemetry-php-contrib] [opentelemetry-auto-symfony] http.route uses route name instead of route template path #1841

@Apoorva64

Description

@Apoorva64

Describe your environment

  • PHP version: 8.4
  • open-telemetry/opentelemetry-auto-symfony: ^1.1.1
  • Symfony: 8
  • OS: Linux

Steps to reproduce

  1. Create a Symfony application with a route that has path parameters:
<?php
#[Route('/v1/payments/{paymentId}/capture', name: 'api_payments_capture', methods: ['POST'])]
public function capture(string $paymentId): Response
{
    return new JsonResponse(['id' => $paymentId]);
}
  1. Make a request to POST /v1/payments/abc123/capture
  2. Inspect the generated span in your tracing backend (Jaeger, etc.) in http.route will be "api_payments_capture"

What is the expected behavior?
Per OpenTelemetry HTTP semantic conventions, http.route should be "the matched route template for the request. This MUST be low-cardinality and include all static path segments, with dynamic path segments represented with placeholders"

  • http.route: /v1/payments/{paymentId}/capture

What is the actual behavior?
The instrumentation uses the Symfony route name from $request->attributes->get('_route'):

  • http.route: api_payments_capture

Additional context
Current workaround is to use an event subscriber that modifies _route before the instrumentation reads it, but this is fragile and could affect other application logic that depends on the route name.

Tip: React with 👍 to help prioritize this issue. Please use comments to provide useful context, avoiding +1 or me too, to help us triage it. Learn more here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions