diff --git a/src/OpenTelemetry.Instrumentation.Http/Implementation/HttpHandlerDiagnosticListener.cs b/src/OpenTelemetry.Instrumentation.Http/Implementation/HttpHandlerDiagnosticListener.cs index 5013b46c8a2..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; @@ -41,27 +39,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 +80,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); }