diff --git a/src/OpenTelemetry.Instrumentation.AspNetCore/CHANGELOG.md b/src/OpenTelemetry.Instrumentation.AspNetCore/CHANGELOG.md index 65fdeb38f..e6aec0c5f 100644 --- a/src/OpenTelemetry.Instrumentation.AspNetCore/CHANGELOG.md +++ b/src/OpenTelemetry.Instrumentation.AspNetCore/CHANGELOG.md @@ -6,6 +6,10 @@ `net.host.name` and `net.host.port` attributes will be populated instead. ([#3858](https://github.com/open-telemetry/opentelemetry-dotnet/pull/3858)) +* The `http.server.duration` metric's `http.target` attribute is replaced +with `http.route` attribute. +([#3903](https://github.com/open-telemetry/opentelemetry-dotnet/pull/3903)) + ## 1.0.0-rc9.9 Released 2022-Nov-07 diff --git a/src/OpenTelemetry.Instrumentation.AspNetCore/Implementation/HttpInMetricsListener.cs b/src/OpenTelemetry.Instrumentation.AspNetCore/Implementation/HttpInMetricsListener.cs index 802feedec..cf6c66bd9 100644 --- a/src/OpenTelemetry.Instrumentation.AspNetCore/Implementation/HttpInMetricsListener.cs +++ b/src/OpenTelemetry.Instrumentation.AspNetCore/Implementation/HttpInMetricsListener.cs @@ -70,11 +70,11 @@ namespace OpenTelemetry.Instrumentation.AspNetCore.Implementation TagList tags; #if NET6_0_OR_GREATER - var target = (context.GetEndpoint() as RouteEndpoint)?.RoutePattern.RawText; + var route = (context.GetEndpoint() as RouteEndpoint)?.RoutePattern.RawText; // TODO: This is just a minimal set of attributes. See the spec for additional attributes: // https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/semantic_conventions/http-metrics.md#http-server - if (!string.IsNullOrEmpty(target)) + if (!string.IsNullOrEmpty(route)) { tags = new TagList { @@ -82,7 +82,7 @@ namespace OpenTelemetry.Instrumentation.AspNetCore.Implementation { SemanticConventions.AttributeHttpScheme, context.Request.Scheme }, { SemanticConventions.AttributeHttpMethod, context.Request.Method }, { SemanticConventions.AttributeHttpHost, host }, - { SemanticConventions.AttributeHttpTarget, target }, + { SemanticConventions.AttributeHttpRoute, route }, { SemanticConventions.AttributeHttpStatusCode, context.Response.StatusCode.ToString() }, }; } diff --git a/test/OpenTelemetry.Instrumentation.AspNetCore.Tests/MetricTests.cs b/test/OpenTelemetry.Instrumentation.AspNetCore.Tests/MetricTests.cs index 8cef78f44..dff0246e7 100644 --- a/test/OpenTelemetry.Instrumentation.AspNetCore.Tests/MetricTests.cs +++ b/test/OpenTelemetry.Instrumentation.AspNetCore.Tests/MetricTests.cs @@ -120,13 +120,13 @@ namespace OpenTelemetry.Instrumentation.AspNetCore.Tests var statusCode = new KeyValuePair(SemanticConventions.AttributeHttpStatusCode, "200"); var flavor = new KeyValuePair(SemanticConventions.AttributeHttpFlavor, "1.1"); var host = new KeyValuePair(SemanticConventions.AttributeHttpHost, "localhost"); - var target = new KeyValuePair(SemanticConventions.AttributeHttpTarget, "api/Values"); + var route = new KeyValuePair(SemanticConventions.AttributeHttpRoute, "api/Values"); Assert.Contains(method, attributes); Assert.Contains(scheme, attributes); Assert.Contains(statusCode, attributes); Assert.Contains(flavor, attributes); Assert.Contains(host, attributes); - Assert.Contains(target, attributes); + Assert.Contains(route, attributes); Assert.Equal(6, attributes.Length); }