From a9cf48022e66643d925fcfe203b36b6deeb03670 Mon Sep 17 00:00:00 2001 From: Cijo Thomas Date: Fri, 17 Jun 2022 13:03:14 -0700 Subject: [PATCH 1/2] Fix AspNetCore metrics to use correct value for http.flavor --- src/OpenTelemetry.Instrumentation.AspNetCore/CHANGELOG.md | 3 +++ .../Implementation/HttpInMetricsListener.cs | 4 ++-- .../MetricTests.cs | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/OpenTelemetry.Instrumentation.AspNetCore/CHANGELOG.md b/src/OpenTelemetry.Instrumentation.AspNetCore/CHANGELOG.md index f4a4ac365a..13691ec175 100644 --- a/src/OpenTelemetry.Instrumentation.AspNetCore/CHANGELOG.md +++ b/src/OpenTelemetry.Instrumentation.AspNetCore/CHANGELOG.md @@ -2,6 +2,9 @@ ## Unreleased +* Metrics instrumentation to correctly populate 'http.flavor' tag. + ([3373](https://github.com/open-telemetry/opentelemetry-dotnet/pull/3373)) + * 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 2becf9cf12..6d99477051 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 9251223066..53bac48fac 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); From 39deb70a55f1c486b59c7b30a7e52a17690beb0b Mon Sep 17 00:00:00 2001 From: Cijo Thomas Date: Fri, 17 Jun 2022 13:06:42 -0700 Subject: [PATCH 2/2] word better --- src/OpenTelemetry.Instrumentation.AspNetCore/CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/OpenTelemetry.Instrumentation.AspNetCore/CHANGELOG.md b/src/OpenTelemetry.Instrumentation.AspNetCore/CHANGELOG.md index 13691ec175..6e50bf60f8 100644 --- a/src/OpenTelemetry.Instrumentation.AspNetCore/CHANGELOG.md +++ b/src/OpenTelemetry.Instrumentation.AspNetCore/CHANGELOG.md @@ -3,7 +3,8 @@ ## Unreleased * Metrics instrumentation to correctly populate 'http.flavor' tag. - ([3373](https://github.com/open-telemetry/opentelemetry-dotnet/pull/3373)) + (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))