open-telemetry / open-telemetry/opentelemetry-php

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

Open
#1,841 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
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

  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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.