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
- Create an ASP.NET app with a generic route like
api/{controller}/{id} that maps to multiple controllers
- Set
DD_TRACE_EXPAND_ROUTE_TEMPLATES_ENABLED=true
- 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
Description
When
DD_TRACE_EXPAND_ROUTE_TEMPLATES_ENABLED=trueis set, theresource_nameis correctly expanded (e.g.,{controller}is replaced with the actual controller name), but thehttp.routespan tag retains the raw ASP.NET route template without expansion.Expected Behavior
Both
resource_nameandhttp.routeshould reflect the expanded route whenDD_TRACE_EXPAND_ROUTE_TEMPLATES_ENABLED=trueis enabled. For example, if the route template isapi/{controller}/{id}, both attributes should showapi/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.routefor 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,HttpRouteis set to the rawrouteUrl(route.Url) before any expansion:The
expandRouteTemplatesparameter is only passed toCalculateResourceName()for computing the resource name — it is never applied to thehttp.routetag.The same pattern exists in
AspNetWebApi2Integration.csandAspNetCoreDiagnosticObserver.cs.Reproduction
api/{controller}/{id}that maps to multiple controllersDD_TRACE_EXPAND_ROUTE_TEMPLATES_ENABLED=trueresource_namehas the controller expanded buthttp.routestill contains{controller}Impact
The Datadog APM endpoints page uses
http.routefor the displayed path andresource_namefor the copied name. This inconsistency causes:{controller}entry)