From 7c098e72f8a7be6fa17d0cc9722d380852cd04fe Mon Sep 17 00:00:00 2001 From: Vishwesh Bankwar Date: Mon, 6 Mar 2023 12:52:16 -0800 Subject: [PATCH] [ASP.NET Core] Do not reset baggage on requeststop --- .../Implementation/HttpInListener.cs | 6 ------ .../BasicTests.cs | 4 ++-- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/src/OpenTelemetry.Instrumentation.AspNetCore/Implementation/HttpInListener.cs b/src/OpenTelemetry.Instrumentation.AspNetCore/Implementation/HttpInListener.cs index 15bb59e0cb2..c2086c23ba3 100644 --- a/src/OpenTelemetry.Instrumentation.AspNetCore/Implementation/HttpInListener.cs +++ b/src/OpenTelemetry.Instrumentation.AspNetCore/Implementation/HttpInListener.cs @@ -286,12 +286,6 @@ public void OnStopActivity(Activity activity, object payload) // the one created by the instrumentation. // And retrieve it here, and set it to Current. } - - var textMapPropagator = Propagators.DefaultTextMapPropagator; - if (textMapPropagator is not TraceContextPropagator) - { - Baggage.Current = default; - } } public void OnMvcBeforeAction(Activity activity, object payload) diff --git a/test/OpenTelemetry.Instrumentation.AspNetCore.Tests/BasicTests.cs b/test/OpenTelemetry.Instrumentation.AspNetCore.Tests/BasicTests.cs index 852b7d716e5..d8b3737ead0 100644 --- a/test/OpenTelemetry.Instrumentation.AspNetCore.Tests/BasicTests.cs +++ b/test/OpenTelemetry.Instrumentation.AspNetCore.Tests/BasicTests.cs @@ -474,7 +474,7 @@ public async Task ExtractContextIrrespectiveOfTheFilterApplied() } [Fact] - public async Task BaggageClearedWhenActivityStopped() + public async Task BaggageIsNotClearedWhenActivityStopped() { int? baggageCountAfterStart = null; int? baggageCountAfterStop = null; @@ -532,7 +532,7 @@ void ConfigureTestServices(IServiceCollection services) Assert.NotNull(baggageCountAfterStart); Assert.Equal(2, baggageCountAfterStart); Assert.NotNull(baggageCountAfterStop); - Assert.Equal(0, baggageCountAfterStop); + Assert.Equal(2, baggageCountAfterStop); } [Theory]