Skip to content

DD_TRACE_EXPAND_ROUTE_TEMPLATES_ENABLED does not expand http.route tag, only resource_name #8319

@majorgreys

Description

@majorgreys

Description

When DD_TRACE_EXPAND_ROUTE_TEMPLATES_ENABLED=true is set, the resource_name is correctly expanded (e.g., {controller} is replaced with the actual controller name), but the http.route span tag retains the raw ASP.NET route template without expansion.

Expected Behavior

Both resource_name and http.route should reflect the expanded route when DD_TRACE_EXPAND_ROUTE_TEMPLATES_ENABLED=true is enabled. For example, if the route template is api/{controller}/{id}, both attributes should show api/users/{id}.

Actual Behavior

  • resource_name: GET /api/users/{id} (expanded correctly)
  • http.route: api/{controller}/{id} (NOT expanded)

This causes the Datadog endpoints page to display duplicate entries because it uses http.route for the display path. Multiple distinct controllers sharing the same route template pattern (e.g., api/{controller}/{id}) all appear as one endpoint.

Root Cause

In AspNetMvcIntegration.cs, HttpRoute is set to the raw routeUrl (route.Url) before any expansion:

tags.AspNetRoute = routeUrl;
// ...
rootAspNetTags.HttpRoute = routeUrl;

The expandRouteTemplates parameter is only passed to CalculateResourceName() for computing the resource name — it is never applied to the http.route tag.

The same pattern exists in AspNetWebApi2Integration.cs and AspNetCoreDiagnosticObserver.cs.

Reproduction

  1. Create an ASP.NET app with a generic route like api/{controller}/{id} that maps to multiple controllers
  2. Set DD_TRACE_EXPAND_ROUTE_TEMPLATES_ENABLED=true
  3. Observe that resource_name has the controller expanded but http.route still contains {controller}

Impact

The Datadog APM endpoints page uses http.route for the displayed path and resource_name for the copied name. This inconsistency causes:

  • Apparent duplicate endpoints in the UI (many controllers collapse into one {controller} entry)
  • Confusing copy behavior where the copied value differs from what is displayed

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions