Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove SetHttpFlavor from Http instrumentations #3381

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ OpenTelemetry.Instrumentation.Http.HttpClientInstrumentationOptions.Filter.set -
OpenTelemetry.Instrumentation.Http.HttpClientInstrumentationOptions.HttpClientInstrumentationOptions() -> void
OpenTelemetry.Instrumentation.Http.HttpClientInstrumentationOptions.RecordException.get -> bool
OpenTelemetry.Instrumentation.Http.HttpClientInstrumentationOptions.RecordException.set -> void
OpenTelemetry.Instrumentation.Http.HttpClientInstrumentationOptions.SetHttpFlavor.get -> bool
OpenTelemetry.Instrumentation.Http.HttpClientInstrumentationOptions.SetHttpFlavor.set -> void
OpenTelemetry.Instrumentation.Http.HttpWebRequestInstrumentationOptions
OpenTelemetry.Instrumentation.Http.HttpWebRequestInstrumentationOptions.Enrich.get -> System.Action<System.Diagnostics.Activity, string, object>
OpenTelemetry.Instrumentation.Http.HttpWebRequestInstrumentationOptions.Enrich.set -> void
Expand All @@ -16,8 +14,6 @@ OpenTelemetry.Instrumentation.Http.HttpWebRequestInstrumentationOptions.Filter.s
OpenTelemetry.Instrumentation.Http.HttpWebRequestInstrumentationOptions.HttpWebRequestInstrumentationOptions() -> void
OpenTelemetry.Instrumentation.Http.HttpWebRequestInstrumentationOptions.RecordException.get -> bool
OpenTelemetry.Instrumentation.Http.HttpWebRequestInstrumentationOptions.RecordException.set -> void
OpenTelemetry.Instrumentation.Http.HttpWebRequestInstrumentationOptions.SetHttpFlavor.get -> bool
OpenTelemetry.Instrumentation.Http.HttpWebRequestInstrumentationOptions.SetHttpFlavor.set -> void
OpenTelemetry.Metrics.MeterProviderBuilderExtensions
OpenTelemetry.Trace.TracerProviderBuilderExtensions
static OpenTelemetry.Metrics.MeterProviderBuilderExtensions.AddHttpClientInstrumentation(this OpenTelemetry.Metrics.MeterProviderBuilder builder) -> OpenTelemetry.Metrics.MeterProviderBuilder
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ OpenTelemetry.Instrumentation.Http.HttpClientInstrumentationOptions.Filter.set -
OpenTelemetry.Instrumentation.Http.HttpClientInstrumentationOptions.HttpClientInstrumentationOptions() -> void
OpenTelemetry.Instrumentation.Http.HttpClientInstrumentationOptions.RecordException.get -> bool
OpenTelemetry.Instrumentation.Http.HttpClientInstrumentationOptions.RecordException.set -> void
OpenTelemetry.Instrumentation.Http.HttpClientInstrumentationOptions.SetHttpFlavor.get -> bool
OpenTelemetry.Instrumentation.Http.HttpClientInstrumentationOptions.SetHttpFlavor.set -> void
OpenTelemetry.Metrics.MeterProviderBuilderExtensions
OpenTelemetry.Trace.TracerProviderBuilderExtensions
static OpenTelemetry.Metrics.MeterProviderBuilderExtensions.AddHttpClientInstrumentation(this OpenTelemetry.Metrics.MeterProviderBuilder builder) -> OpenTelemetry.Metrics.MeterProviderBuilder
Expand Down
5 changes: 5 additions & 0 deletions src/OpenTelemetry.Instrumentation.Http/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

## Unreleased

* [Breaking] Removes `SetHttpFlavor` option. "http.flavor" is
now always automatically populated.
To remove this tag, set "http.flavor" to null using `ActivityProcessor`.
([#3380](https://github.com/open-telemetry/opentelemetry-dotnet/issues/3380))

## 1.0.0-rc9.4

Released 2022-Jun-03
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
using System.Net.Http;
using System.Runtime.CompilerServices;
using OpenTelemetry.Instrumentation.Http.Implementation;
using OpenTelemetry.Trace;

namespace OpenTelemetry.Instrumentation.Http
{
Expand All @@ -28,11 +27,6 @@ namespace OpenTelemetry.Instrumentation.Http
/// </summary>
public class HttpClientInstrumentationOptions
{
/// <summary>
/// Gets or sets a value indicating whether or not the HTTP version should be added as the <see cref="SemanticConventions.AttributeHttpFlavor"/> tag. Default value: False.
/// </summary>
public bool SetHttpFlavor { get; set; }

/// <summary>
/// Gets or sets a Filter function that determines whether or not to collect telemetry about requests on a per request basis.
/// The Filter gets the HttpRequestMessage, and should return a boolean.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
using System.Diagnostics;
using System.Net;
using OpenTelemetry.Instrumentation.Http.Implementation;
using OpenTelemetry.Trace;

namespace OpenTelemetry.Instrumentation.Http
{
Expand All @@ -28,11 +27,6 @@ namespace OpenTelemetry.Instrumentation.Http
/// </summary>
public class HttpWebRequestInstrumentationOptions
{
/// <summary>
/// Gets or sets a value indicating whether or not the HTTP version should be added as the <see cref="SemanticConventions.AttributeHttpFlavor"/> tag. Default value: False.
/// </summary>
public bool SetHttpFlavor { get; set; }

/// <summary>
/// Gets or sets a Filter function that determines whether or not to collect telemetry about requests on a per request basis.
/// The Filter gets the HttpWebRequest, and should return a boolean.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,7 @@ public override void OnStartActivity(Activity activity, object payload)
activity.SetTag(SemanticConventions.AttributeHttpMethod, HttpTagHelper.GetNameForHttpMethod(request.Method));
activity.SetTag(SemanticConventions.AttributeHttpHost, HttpTagHelper.GetHostTagValueFromRequestUri(request.RequestUri));
activity.SetTag(SemanticConventions.AttributeHttpUrl, HttpTagHelper.GetUriTagValueFromRequestUri(request.RequestUri));
if (this.options.SetHttpFlavor)
{
activity.SetTag(SemanticConventions.AttributeHttpFlavor, HttpTagHelper.GetFlavorTagValueFromProtocolVersion(request.Version));
}
activity.SetTag(SemanticConventions.AttributeHttpFlavor, HttpTagHelper.GetFlavorTagValueFromProtocolVersion(request.Version));

try
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,7 @@ private static void AddRequestTagsAndInstrumentRequest(HttpWebRequest request, A
activity.SetTag(SemanticConventions.AttributeHttpMethod, request.Method);
activity.SetTag(SemanticConventions.AttributeHttpHost, HttpTagHelper.GetHostTagValueFromRequestUri(request.RequestUri));
activity.SetTag(SemanticConventions.AttributeHttpUrl, HttpTagHelper.GetUriTagValueFromRequestUri(request.RequestUri));
if (Options.SetHttpFlavor)
{
activity.SetTag(SemanticConventions.AttributeHttpFlavor, HttpTagHelper.GetFlavorTagValueFromProtocolVersion(request.ProtocolVersion));
}
activity.SetTag(SemanticConventions.AttributeHttpFlavor, HttpTagHelper.GetFlavorTagValueFromProtocolVersion(request.ProtocolVersion));

try
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ public async Task HttpOutCallsAreCollectedSuccessfullyAsync(HttpTestData.HttpOut
using (Sdk.CreateTracerProviderBuilder()
.AddHttpClientInstrumentation((opt) =>
{
opt.SetHttpFlavor = tc.SetHttpFlavor;
opt.Enrich = ActivityEnrichment;
opt.RecordException = tc.RecordException ?? false;
})
Expand Down Expand Up @@ -202,6 +201,7 @@ public async Task DebugIndividualTestAsync()
""http.method"": ""GET"",
""http.host"": ""{host}:{port}"",
""http.status_code"": ""399"",
""http.flavor"": ""2.0"",
""http.url"": ""http://{host}:{port}/""
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,6 @@ public class HttpOutTestCase
public bool? SpanStatusHasDescription { get; set; }

public Dictionary<string, string> SpanAttributes { get; set; }

public bool SetHttpFlavor { get; set; }
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ public void HttpOutCallsAreCollectedSuccessfully(HttpTestData.HttpOutTestCase tc
.AddProcessor(activityProcessor.Object)
.AddHttpClientInstrumentation(options =>
{
options.SetHttpFlavor = tc.SetHttpFlavor;
options.Enrich = ActivityEnrichment;
options.RecordException = tc.RecordException.HasValue ? tc.RecordException.Value : false;
})
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[
[
{
"name": "Successful GET call to localhost",
"method": "GET",
Expand All @@ -9,6 +9,7 @@
"spanAttributes": {
"http.method": "GET",
"http.host": "{host}:{port}",
"http.flavor": "2.0",
"http.status_code": 200,
"http.url": "http://{host}:{port}/"
}
Expand All @@ -23,6 +24,7 @@
"spanAttributes": {
"http.method": "POST",
"http.host": "{host}:{port}",
"http.flavor": "2.0",
"http.status_code": 200,
"http.url": "http://{host}:{port}/"
}
Expand All @@ -38,6 +40,7 @@
"spanAttributes": {
"http.method": "GET",
"http.host": "{host}:{port}",
"http.flavor": "2.0",
"http.status_code": 200,
"http.url": "http://{host}:{port}/path/to/resource/"
}
Expand All @@ -53,6 +56,7 @@
"spanAttributes": {
"http.method": "GET",
"http.host": "{host}:{port}",
"http.flavor": "2.0",
"http.status_code": 200,
"http.url": "http://{host}:{port}/path/to/resource#fragment"
}
Expand All @@ -68,6 +72,7 @@
"spanAttributes": {
"http.method": "GET",
"http.host": "{host}:{port}",
"http.flavor": "2.0",
"http.status_code": 200,
"http.url": "http://{host}:{port}/path/to/resource#fragment"
}
Expand All @@ -84,6 +89,7 @@
"spanAttributes": {
"http.method": "GET",
"http.host": "sdlfaldfjalkdfjlkajdflkajlsdjf.sdlkjafsdjfalfadslkf.com",
"http.flavor": "2.0",
"http.url": "https://sdlfaldfjalkdfjlkajdflkajlsdjf.sdlkjafsdjfalfadslkf.com/"
}
},
Expand All @@ -99,6 +105,7 @@
"spanAttributes": {
"http.method": "GET",
"http.host": "sdlfaldfjalkdfjlkajdflkajlsdjf.sdlkjafsdjfalfadslkf.com",
"http.flavor": "2.0",
"http.url": "https://sdlfaldfjalkdfjlkajdflkajlsdjf.sdlkjafsdjfalfadslkf.com/"
}
},
Expand All @@ -113,6 +120,7 @@
"spanAttributes": {
"http.method": "GET",
"http.host": "{host}:{port}",
"http.flavor": "2.0",
"http.status_code": 200,
"http.url": "http://{host}:{port}/"
}
Expand All @@ -128,6 +136,7 @@
"spanAttributes": {
"http.method": "GET",
"http.host": "{host}:{port}",
"http.flavor": "2.0",
"http.status_code": 200,
"http.url": "http://{host}:{port}/"
}
Expand All @@ -143,6 +152,7 @@
"spanAttributes": {
"http.method": "GET",
"http.host": "{host}:{port}",
"http.flavor": "2.0",
"http.status_code": "399",
"http.url": "http://{host}:{port}/"
}
Expand All @@ -158,6 +168,7 @@
"spanAttributes": {
"http.method": "GET",
"http.host": "{host}:{port}",
"http.flavor": "2.0",
"http.status_code": "400",
"http.url": "http://{host}:{port}/"
}
Expand All @@ -173,6 +184,7 @@
"spanAttributes": {
"http.method": "GET",
"http.host": "{host}:{port}",
"http.flavor": "2.0",
"http.status_code": "401",
"http.url": "http://{host}:{port}/"
}
Expand All @@ -188,6 +200,7 @@
"spanAttributes": {
"http.method": "GET",
"http.host": "{host}:{port}",
"http.flavor": "2.0",
"http.status_code": "403",
"http.url": "http://{host}:{port}/"
}
Expand All @@ -203,6 +216,7 @@
"spanAttributes": {
"http.method": "GET",
"http.host": "{host}:{port}",
"http.flavor": "2.0",
"http.status_code": "404",
"http.url": "http://{host}:{port}/"
}
Expand All @@ -218,6 +232,7 @@
"spanAttributes": {
"http.method": "GET",
"http.host": "{host}:{port}",
"http.flavor": "2.0",
"http.status_code": "429",
"http.url": "http://{host}:{port}/"
}
Expand All @@ -233,6 +248,7 @@
"spanAttributes": {
"http.method": "GET",
"http.host": "{host}:{port}",
"http.flavor": "2.0",
"http.status_code": "501",
"http.url": "http://{host}:{port}/"
}
Expand All @@ -248,6 +264,7 @@
"spanAttributes": {
"http.method": "GET",
"http.host": "{host}:{port}",
"http.flavor": "2.0",
"http.status_code": "503",
"http.url": "http://{host}:{port}/"
}
Expand All @@ -263,6 +280,7 @@
"spanAttributes": {
"http.method": "GET",
"http.host": "{host}:{port}",
"http.flavor": "2.0",
"http.status_code": "504",
"http.url": "http://{host}:{port}/"
}
Expand All @@ -278,6 +296,7 @@
"spanAttributes": {
"http.method": "GET",
"http.host": "{host}:{port}",
"http.flavor": "2.0",
"http.status_code": "600",
"http.url": "http://{host}:{port}/"
}
Expand All @@ -290,7 +309,6 @@
"spanName": "HTTP GET",
"spanStatus": "UNSET",
"responseExpected": true,
"setHttpFlavor": true,
"spanAttributes": {
"http.method": "GET",
"http.host": "{host}:{port}",
Expand Down