From 24cff5886068d5a3ea52259d60fae478e6ff7e3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Kie=C5=82kowicz?= Date: Fri, 8 Mar 2024 06:58:59 +0100 Subject: [PATCH] Revert changes for metrics --- src/OpenTelemetry.Instrumentation.AspNetCore/CHANGELOG.md | 5 +++-- .../Implementation/HttpHandlerMetricsDiagnosticListener.cs | 5 ++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/OpenTelemetry.Instrumentation.AspNetCore/CHANGELOG.md b/src/OpenTelemetry.Instrumentation.AspNetCore/CHANGELOG.md index df9d7191830..5b608371d46 100644 --- a/src/OpenTelemetry.Instrumentation.AspNetCore/CHANGELOG.md +++ b/src/OpenTelemetry.Instrumentation.AspNetCore/CHANGELOG.md @@ -2,8 +2,9 @@ ## Unreleased -* Fixed an issue when `server.port` attribute was not set with `server.address` - when it has default values (`80` for `HTTP` and `443` for `HTTPS` protocol). +* Fixed an issue for spans when `server.port` attribute was not set with + `server.address` when it has default values (`80` for `HTTP` and + `443` for `HTTPS` protocol). ([#5419](https://github.com/open-telemetry/opentelemetry-dotnet/pull/5419)) ## 1.7.1 diff --git a/src/OpenTelemetry.Instrumentation.Http/Implementation/HttpHandlerMetricsDiagnosticListener.cs b/src/OpenTelemetry.Instrumentation.Http/Implementation/HttpHandlerMetricsDiagnosticListener.cs index 6da5982f8f4..42790be05c4 100644 --- a/src/OpenTelemetry.Instrumentation.Http/Implementation/HttpHandlerMetricsDiagnosticListener.cs +++ b/src/OpenTelemetry.Instrumentation.Http/Implementation/HttpHandlerMetricsDiagnosticListener.cs @@ -52,7 +52,10 @@ public static void OnStopEventWritten(Activity activity, object payload) tags.Add(new KeyValuePair(SemanticConventions.AttributeServerAddress, request.RequestUri.Host)); tags.Add(new KeyValuePair(SemanticConventions.AttributeServerPort, request.RequestUri.Port)); - tags.Add(new KeyValuePair(SemanticConventions.AttributeUrlScheme, request.RequestUri.Scheme)); + if (!request.RequestUri.IsDefaultPort) + { + tags.Add(new KeyValuePair(SemanticConventions.AttributeUrlScheme, request.RequestUri.Scheme)); + } if (TryFetchResponse(payload, out HttpResponseMessage response)) {