From 3a32897139e3266bdf91ac678a9ee58c4dcf7e79 Mon Sep 17 00:00:00 2001 From: Vishwesh Bankwar Date: Wed, 27 Apr 2022 14:19:01 -0700 Subject: [PATCH 1/2] remove w3c check --- .../HttpHandlerDiagnosticListener.cs | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) diff --git a/src/OpenTelemetry.Instrumentation.Http/Implementation/HttpHandlerDiagnosticListener.cs b/src/OpenTelemetry.Instrumentation.Http/Implementation/HttpHandlerDiagnosticListener.cs index 5013b46c8a2..d69a5910a14 100644 --- a/src/OpenTelemetry.Instrumentation.Http/Implementation/HttpHandlerDiagnosticListener.cs +++ b/src/OpenTelemetry.Instrumentation.Http/Implementation/HttpHandlerDiagnosticListener.cs @@ -41,27 +41,11 @@ internal sealed class HttpHandlerDiagnosticListener : ListenerHandler private readonly PropertyFetcher stopResponseFetcher = new("Response"); private readonly PropertyFetcher stopExceptionFetcher = new("Exception"); private readonly PropertyFetcher stopRequestStatusFetcher = new("RequestTaskStatus"); - private readonly bool httpClientSupportsW3C; private readonly HttpClientInstrumentationOptions options; public HttpHandlerDiagnosticListener(HttpClientInstrumentationOptions options) : base("HttpHandlerDiagnosticListener") { - var framework = Assembly - .GetEntryAssembly()? - .GetCustomAttribute()? - .FrameworkName; - - // Depending on the .NET version/flavor this will look like - // '.NETCoreApp,Version=v3.0', '.NETCoreApp,Version = v2.2' or '.NETFramework,Version = v4.7.1' - - if (framework != null) - { - var match = CoreAppMajorVersionCheckRegex.Match(framework); - - this.httpClientSupportsW3C = match.Success && int.Parse(match.Groups[1].Value, CultureInfo.InvariantCulture) >= 3; - } - this.options = options; } @@ -98,7 +82,7 @@ public override void OnStartActivity(Activity activity, object payload) // Propagate context irrespective of sampling decision var textMapPropagator = Propagators.DefaultTextMapPropagator; - if (!(this.httpClientSupportsW3C && textMapPropagator is TraceContextPropagator)) + if (textMapPropagator is not TraceContextPropagator) { textMapPropagator.Inject(new PropagationContext(activity.Context, Baggage.Current), request, HttpRequestMessageContextPropagation.HeaderValueSetter); } From ee35de9fc07e4a667c1edf6cee4d4f1b6fb493df Mon Sep 17 00:00:00 2001 From: Vishwesh Bankwar Date: Wed, 27 Apr 2022 14:38:49 -0700 Subject: [PATCH 2/2] unnecessary usings --- .../Implementation/HttpHandlerDiagnosticListener.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/OpenTelemetry.Instrumentation.Http/Implementation/HttpHandlerDiagnosticListener.cs b/src/OpenTelemetry.Instrumentation.Http/Implementation/HttpHandlerDiagnosticListener.cs index d69a5910a14..c07cf4ecd72 100644 --- a/src/OpenTelemetry.Instrumentation.Http/Implementation/HttpHandlerDiagnosticListener.cs +++ b/src/OpenTelemetry.Instrumentation.Http/Implementation/HttpHandlerDiagnosticListener.cs @@ -16,11 +16,9 @@ using System; using System.Diagnostics; -using System.Globalization; using System.Net.Http; using System.Net.Sockets; using System.Reflection; -using System.Runtime.Versioning; using System.Text.RegularExpressions; using System.Threading.Tasks; using OpenTelemetry.Context.Propagation;