diff --git a/src/OpenTelemetry.Instrumentation.AspNetCore/CHANGELOG.md b/src/OpenTelemetry.Instrumentation.AspNetCore/CHANGELOG.md index f4a4ac365a6..6e50bf60f8e 100644 --- a/src/OpenTelemetry.Instrumentation.AspNetCore/CHANGELOG.md +++ b/src/OpenTelemetry.Instrumentation.AspNetCore/CHANGELOG.md @@ -2,6 +2,10 @@ ## Unreleased +* Metrics instrumentation to correctly populate 'http.flavor' tag. + (1.1 instead of HTTP/1.1 etc.) + ([3379](https://github.com/open-telemetry/opentelemetry-dotnet/pull/3379)) + * Tracing instrumentation to populate 'http.flavor' tag. ([3372](https://github.com/open-telemetry/opentelemetry-dotnet/pull/3372)) diff --git a/src/OpenTelemetry.Instrumentation.AspNetCore/Implementation/HttpInMetricsListener.cs b/src/OpenTelemetry.Instrumentation.AspNetCore/Implementation/HttpInMetricsListener.cs index 2becf9cf128..6d99477051f 100644 --- a/src/OpenTelemetry.Instrumentation.AspNetCore/Implementation/HttpInMetricsListener.cs +++ b/src/OpenTelemetry.Instrumentation.AspNetCore/Implementation/HttpInMetricsListener.cs @@ -78,7 +78,7 @@ public override void OnStopActivity(Activity activity, object payload) { tags = new TagList { - { SemanticConventions.AttributeHttpFlavor, context.Request.Protocol }, + { SemanticConventions.AttributeHttpFlavor, HttpTagHelper.GetFlavorTagValueFromProtocol(context.Request.Protocol) }, { SemanticConventions.AttributeHttpScheme, context.Request.Scheme }, { SemanticConventions.AttributeHttpMethod, context.Request.Method }, { SemanticConventions.AttributeHttpHost, host }, @@ -90,7 +90,7 @@ public override void OnStopActivity(Activity activity, object payload) { tags = new TagList { - { SemanticConventions.AttributeHttpFlavor, context.Request.Protocol }, + { SemanticConventions.AttributeHttpFlavor, HttpTagHelper.GetFlavorTagValueFromProtocol(context.Request.Protocol) }, { SemanticConventions.AttributeHttpScheme, context.Request.Scheme }, { SemanticConventions.AttributeHttpMethod, context.Request.Method }, { SemanticConventions.AttributeHttpHost, host }, diff --git a/test/OpenTelemetry.Instrumentation.AspNetCore.Tests/MetricTests.cs b/test/OpenTelemetry.Instrumentation.AspNetCore.Tests/MetricTests.cs index 92512230663..53bac48facc 100644 --- a/test/OpenTelemetry.Instrumentation.AspNetCore.Tests/MetricTests.cs +++ b/test/OpenTelemetry.Instrumentation.AspNetCore.Tests/MetricTests.cs @@ -117,7 +117,7 @@ public async Task RequestMetricIsCaptured() var method = new KeyValuePair(SemanticConventions.AttributeHttpMethod, "GET"); var scheme = new KeyValuePair(SemanticConventions.AttributeHttpScheme, "http"); var statusCode = new KeyValuePair(SemanticConventions.AttributeHttpStatusCode, "200"); - var flavor = new KeyValuePair(SemanticConventions.AttributeHttpFlavor, "HTTP/1.1"); + var flavor = new KeyValuePair(SemanticConventions.AttributeHttpFlavor, "1.1"); var host = new KeyValuePair(SemanticConventions.AttributeHttpHost, "localhost"); var target = new KeyValuePair(SemanticConventions.AttributeHttpTarget, "api/Values"); Assert.Contains(method, attributes);