open-telemetry / open-telemetry/opentelemetry-php
[opentelemetry-php-contrib] [opentelemetry-auto-symfony] http.route uses route name instead of route template path
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 912
- Forks
- 232
- Avg merge
- 7d 16h
- Merged PRs (30d)
- 4
Description
Describe your environment
- PHP version: 8.4
- open-telemetry/opentelemetry-auto-symfony: ^1.1.1
- Symfony: 8
- OS: Linux
Steps to reproduce
- 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]);
}
- Make a request to POST /v1/payments/abc123/capture
- 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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in the Symfony instrumentation at the point where http.route is read from $request->attributes->get('_route'). Reproduce the POST request from the issue and compare the emitted span with the OpenTelemetry HTTP semantic conventions; done means http.route contains /v1/payments/{paymentId}/capture rather than api_payments_capture.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php, symfony
- Domain
- api, backend, observability
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100