diff --git a/src/OpenTelemetry.Instrumentation.Http/CHANGELOG.md b/src/OpenTelemetry.Instrumentation.Http/CHANGELOG.md index d3158da9348..1aa38220666 100644 --- a/src/OpenTelemetry.Instrumentation.Http/CHANGELOG.md +++ b/src/OpenTelemetry.Instrumentation.Http/CHANGELOG.md @@ -2,6 +2,10 @@ ## Unreleased +* In case of .NET Core, additional spans created during retries will now be +exported. +([[#3729](https://github.com/open-telemetry/opentelemetry-dotnet/issues/3729)]) + ## 1.0.0-rc9.7 Released 2022-Sep-29 diff --git a/src/OpenTelemetry.Instrumentation.Http/HttpRequestMessageContextPropagation.cs b/src/OpenTelemetry.Instrumentation.Http/HttpRequestMessageContextPropagation.cs index 16999593811..14b26850e97 100644 --- a/src/OpenTelemetry.Instrumentation.Http/HttpRequestMessageContextPropagation.cs +++ b/src/OpenTelemetry.Instrumentation.Http/HttpRequestMessageContextPropagation.cs @@ -34,6 +34,7 @@ internal static class HttpRequestMessageContextPropagation internal static Action HeaderValueSetter => (request, name, value) => { + request.Headers.Remove(name); request.Headers.Add(name, value); }; } diff --git a/src/OpenTelemetry.Instrumentation.Http/Implementation/HttpHandlerDiagnosticListener.cs b/src/OpenTelemetry.Instrumentation.Http/Implementation/HttpHandlerDiagnosticListener.cs index 2b1e741906d..7b066c0c755 100644 --- a/src/OpenTelemetry.Instrumentation.Http/Implementation/HttpHandlerDiagnosticListener.cs +++ b/src/OpenTelemetry.Instrumentation.Http/Implementation/HttpHandlerDiagnosticListener.cs @@ -115,14 +115,6 @@ public void OnStartActivity(Activity activity, object payload) return; } - // TODO: Investigate why this check is needed. - if (Propagators.DefaultTextMapPropagator.Extract(default, request, HttpRequestMessageContextPropagation.HeaderValuesGetter) != default) - { - // this request is already instrumented, we should back off - activity.IsAllDataRequested = false; - return; - } - // Propagate context irrespective of sampling decision var textMapPropagator = Propagators.DefaultTextMapPropagator; if (textMapPropagator is not TraceContextPropagator) diff --git a/test/OpenTelemetry.Instrumentation.Http.Tests/HttpClientTests.Basic.cs b/test/OpenTelemetry.Instrumentation.Http.Tests/HttpClientTests.Basic.cs index df742c63634..8d7581e49fe 100644 --- a/test/OpenTelemetry.Instrumentation.Http.Tests/HttpClientTests.Basic.cs +++ b/test/OpenTelemetry.Instrumentation.Http.Tests/HttpClientTests.Basic.cs @@ -301,7 +301,7 @@ public async Task HttpClientInstrumentation_AddViaFactory_HttpInstrumentation_Co Assert.IsType(processor.Invocations[1].Arguments[0]); } - [Fact(Skip = "https://github.com/open-telemetry/opentelemetry-dotnet/issues/3729")] + [Fact] public async Task HttpClientInstrumentationExportsSpansCreatedForRetries() { var exportedItems = new List(); @@ -321,7 +321,7 @@ public async Task HttpClientInstrumentationExportsSpansCreatedForRetries() await c.SendAsync(request); // number of exported spans should be 3(maxRetries) - Assert.Equal(3, exportedItems.Count()); + Assert.Equal(maxRetries, exportedItems.Count()); var spanid1 = exportedItems[0].SpanId; var spanid2 = exportedItems[1].SpanId;