-
Notifications
You must be signed in to change notification settings - Fork 861
Description
Bug Report
List of all OpenTelemetry NuGet
packages and version that you are
using (e.g. OpenTelemetry 1.0.2):
OpenTelemetry 1.7.0OpenTelemetry.Instrumentation.AspNetCore 1.7.0
Runtime version (e.g. net462, net48, netcoreapp3.1, net6.0 etc. You can
find this information from the *.csproj file):
- net8
Symptom
A clear and concise description of what the bug is.
What is the expected behavior?
http.route should always be populated, regardless of if the route handler threw an exception or not.
What is the actual behavior?
http.route is only populated when there's no exception; the tag is null when an exception occurs.
Reproduce
In lieu of a reproduction repo, I can point to the likely cause, which is a discrepancy between how the metrics instrumentation handles http.route compared to the tracing instrumentation.
- Metrics: , note that it checks
Lines 90 to 96 in 84bdeb3
// Check the exception handler feature first in case the endpoint was overwritten var route = (context.Features.Get<IExceptionHandlerPathFeature>()?.Endpoint as RouteEndpoint ?? context.GetEndpoint() as RouteEndpoint)?.RoutePattern.RawText; if (!string.IsNullOrEmpty(route)) { tags.Add(new KeyValuePair<string, object>(SemanticConventions.AttributeHttpRoute, route)); } context.Features.Get<IExceptionHandlerPathFeature>()?.Endpointfirst, falling back tocontext.GetEndpoint() - Tracing: , note it only checks
opentelemetry-dotnet/src/OpenTelemetry.Instrumentation.AspNetCore/Implementation/HttpInListener.cs
Lines 246 to 252 in 84bdeb3
var routePattern = (context.Features.Get<IExceptionHandlerPathFeature>()?.Endpoint as RouteEndpoint ?? context.GetEndpoint() as RouteEndpoint)?.RoutePattern.RawText; if (!string.IsNullOrEmpty(routePattern)) { RequestMethodHelper.SetActivityDisplayName(activity, context.Request.Method, routePattern); activity.SetTag(SemanticConventions.AttributeHttpRoute, routePattern); } context.GetEndpoint()
I'd assume the metrics way is correct, but am not positive 🤷♂️