From 2d53c9343a0c9b62578a2b11b424a146586a2902 Mon Sep 17 00:00:00 2001 From: Vishwesh Bankwar Date: Wed, 20 Jul 2022 11:04:12 -0700 Subject: [PATCH 1/2] add http.scheme tag --- .../HttpHandlerDiagnosticListener.cs | 1 + .../HttpClientTests.netcore31.cs | 1 + .../http-out-test-cases.json | 20 +++++++++++++++++++ 3 files changed, 22 insertions(+) diff --git a/src/OpenTelemetry.Instrumentation.Http/Implementation/HttpHandlerDiagnosticListener.cs b/src/OpenTelemetry.Instrumentation.Http/Implementation/HttpHandlerDiagnosticListener.cs index 428cce5701f..549537080f9 100644 --- a/src/OpenTelemetry.Instrumentation.Http/Implementation/HttpHandlerDiagnosticListener.cs +++ b/src/OpenTelemetry.Instrumentation.Http/Implementation/HttpHandlerDiagnosticListener.cs @@ -111,6 +111,7 @@ public override void OnStartActivity(Activity activity, object payload) ActivityInstrumentationHelper.SetActivitySourceProperty(activity, ActivitySource); ActivityInstrumentationHelper.SetKindProperty(activity, ActivityKind.Client); + activity.SetTag(SemanticConventions.AttributeHttpScheme, request.RequestUri.Scheme); activity.SetTag(SemanticConventions.AttributeHttpMethod, HttpTagHelper.GetNameForHttpMethod(request.Method)); activity.SetTag(SemanticConventions.AttributeHttpHost, HttpTagHelper.GetHostTagValueFromRequestUri(request.RequestUri)); activity.SetTag(SemanticConventions.AttributeHttpUrl, HttpTagHelper.GetUriTagValueFromRequestUri(request.RequestUri)); diff --git a/test/OpenTelemetry.Instrumentation.Http.Tests/HttpClientTests.netcore31.cs b/test/OpenTelemetry.Instrumentation.Http.Tests/HttpClientTests.netcore31.cs index 43072c3c5f6..27db9e89fba 100644 --- a/test/OpenTelemetry.Instrumentation.Http.Tests/HttpClientTests.netcore31.cs +++ b/test/OpenTelemetry.Instrumentation.Http.Tests/HttpClientTests.netcore31.cs @@ -198,6 +198,7 @@ public async Task DebugIndividualTestAsync() ""spanStatus"": ""UNSET"", ""spanKind"": ""Client"", ""spanAttributes"": { + ""http.scheme"": ""http"", ""http.method"": ""GET"", ""http.host"": ""{host}:{port}"", ""http.status_code"": ""399"", diff --git a/test/OpenTelemetry.Instrumentation.Http.Tests/http-out-test-cases.json b/test/OpenTelemetry.Instrumentation.Http.Tests/http-out-test-cases.json index b938d83305d..aeae7bf8ade 100644 --- a/test/OpenTelemetry.Instrumentation.Http.Tests/http-out-test-cases.json +++ b/test/OpenTelemetry.Instrumentation.Http.Tests/http-out-test-cases.json @@ -7,6 +7,7 @@ "spanStatus": "UNSET", "responseExpected": true, "spanAttributes": { + "http.scheme": "http", "http.method": "GET", "http.host": "{host}:{port}", "http.flavor": "2.0", @@ -22,6 +23,7 @@ "spanStatus": "UNSET", "responseExpected": true, "spanAttributes": { + "http.scheme": "http", "http.method": "POST", "http.host": "{host}:{port}", "http.flavor": "2.0", @@ -38,6 +40,7 @@ "spanStatus": "UNSET", "responseExpected": true, "spanAttributes": { + "http.scheme": "http", "http.method": "GET", "http.host": "{host}:{port}", "http.flavor": "2.0", @@ -54,6 +57,7 @@ "spanStatus": "UNSET", "responseExpected": true, "spanAttributes": { + "http.scheme": "http", "http.method": "GET", "http.host": "{host}:{port}", "http.flavor": "2.0", @@ -70,6 +74,7 @@ "spanStatus": "UNSET", "responseExpected": true, "spanAttributes": { + "http.scheme": "http", "http.method": "GET", "http.host": "{host}:{port}", "http.flavor": "2.0", @@ -87,6 +92,7 @@ "responseExpected": false, "recordException": false, "spanAttributes": { + "http.scheme": "https", "http.method": "GET", "http.host": "sdlfaldfjalkdfjlkajdflkajlsdjf.sdlkjafsdjfalfadslkf.com", "http.flavor": "2.0", @@ -103,6 +109,7 @@ "responseExpected": false, "recordException": true, "spanAttributes": { + "http.scheme": "https", "http.method": "GET", "http.host": "sdlfaldfjalkdfjlkajdflkajlsdjf.sdlkjafsdjfalfadslkf.com", "http.flavor": "2.0", @@ -118,6 +125,7 @@ "spanStatus": "UNSET", "responseExpected": true, "spanAttributes": { + "http.scheme": "http", "http.method": "GET", "http.host": "{host}:{port}", "http.flavor": "2.0", @@ -134,6 +142,7 @@ "spanStatus": "UNSET", "responseExpected": true, "spanAttributes": { + "http.scheme": "http", "http.method": "GET", "http.host": "{host}:{port}", "http.flavor": "2.0", @@ -150,6 +159,7 @@ "spanStatus": "UNSET", "responseExpected": true, "spanAttributes": { + "http.scheme": "http", "http.method": "GET", "http.host": "{host}:{port}", "http.flavor": "2.0", @@ -166,6 +176,7 @@ "spanStatus": "ERROR", "responseExpected": true, "spanAttributes": { + "http.scheme": "http", "http.method": "GET", "http.host": "{host}:{port}", "http.flavor": "2.0", @@ -182,6 +193,7 @@ "spanStatus": "ERROR", "responseExpected": true, "spanAttributes": { + "http.scheme": "http", "http.method": "GET", "http.host": "{host}:{port}", "http.flavor": "2.0", @@ -198,6 +210,7 @@ "spanStatus": "ERROR", "responseExpected": true, "spanAttributes": { + "http.scheme": "http", "http.method": "GET", "http.host": "{host}:{port}", "http.flavor": "2.0", @@ -214,6 +227,7 @@ "spanStatus": "ERROR", "responseExpected": true, "spanAttributes": { + "http.scheme": "http", "http.method": "GET", "http.host": "{host}:{port}", "http.flavor": "2.0", @@ -230,6 +244,7 @@ "spanStatus": "ERROR", "responseExpected": true, "spanAttributes": { + "http.scheme": "http", "http.method": "GET", "http.host": "{host}:{port}", "http.flavor": "2.0", @@ -246,6 +261,7 @@ "spanStatus": "ERROR", "responseExpected": true, "spanAttributes": { + "http.scheme": "http", "http.method": "GET", "http.host": "{host}:{port}", "http.flavor": "2.0", @@ -262,6 +278,7 @@ "spanStatus": "ERROR", "responseExpected": true, "spanAttributes": { + "http.scheme": "http", "http.method": "GET", "http.host": "{host}:{port}", "http.flavor": "2.0", @@ -278,6 +295,7 @@ "spanStatus": "ERROR", "responseExpected": true, "spanAttributes": { + "http.scheme": "http", "http.method": "GET", "http.host": "{host}:{port}", "http.flavor": "2.0", @@ -294,6 +312,7 @@ "spanStatus": "ERROR", "responseExpected": true, "spanAttributes": { + "http.scheme": "http", "http.method": "GET", "http.host": "{host}:{port}", "http.flavor": "2.0", @@ -310,6 +329,7 @@ "spanStatus": "UNSET", "responseExpected": true, "spanAttributes": { + "http.scheme": "http", "http.method": "GET", "http.host": "{host}:{port}", "http.flavor": "2.0", From a54351d472da5c05dc218ad50b6a1e1e3e083974 Mon Sep 17 00:00:00 2001 From: Vishwesh Bankwar Date: Wed, 20 Jul 2022 11:08:40 -0700 Subject: [PATCH 2/2] update changelog --- src/OpenTelemetry.Instrumentation.Http/CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/OpenTelemetry.Instrumentation.Http/CHANGELOG.md b/src/OpenTelemetry.Instrumentation.Http/CHANGELOG.md index 2c22ca8c063..1a5041471bc 100644 --- a/src/OpenTelemetry.Instrumentation.Http/CHANGELOG.md +++ b/src/OpenTelemetry.Instrumentation.Http/CHANGELOG.md @@ -2,6 +2,9 @@ ## Unreleased +* Added `http.scheme` tag to tracing instrumentation. + ([#3464](https://github.com/open-telemetry/opentelemetry-dotnet/pull/3464)) + * [Breaking] Removes `SetHttpFlavor` option. "http.flavor" is now always automatically populated. To remove this tag, set "http.flavor" to null using `ActivityProcessor`.