[ASP.NET Core] Do not reset baggage on request stop event (#4274)

This commit is contained in:
Vishwesh Bankwar 2023-05-05 14:11:12 -07:00 committed by GitHub
parent 25ab11ecda
commit b9908d14f8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 8 deletions

View File

@ -2,6 +2,12 @@
## Unreleased
* Fix issue where baggage gets cleared when the ASP.NET Core Activity
is stopped. The instrumentation no longer clears baggage. One problem
this caused was that it prevented Activity processors from accessing baggage
during their `OnEnd` call.
([#4274](https://github.com/open-telemetry/opentelemetry-dotnet/pull/4274))
* Added direct reference to `System.Text.Encodings.Web` with minimum version of
`4.7.2` due to [CVE-2021-26701](https://github.com/dotnet/runtime/issues/49377).
This impacts target frameworks `netstandard2.0` and `netstandard2.1` which has a

View File

@ -286,12 +286,6 @@ namespace OpenTelemetry.Instrumentation.AspNetCore.Implementation
// 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)

View File

@ -474,7 +474,7 @@ namespace OpenTelemetry.Instrumentation.AspNetCore.Tests
}
[Fact]
public async Task BaggageClearedWhenActivityStopped()
public async Task BaggageIsNotClearedWhenActivityStopped()
{
int? baggageCountAfterStart = null;
int? baggageCountAfterStop = null;
@ -532,7 +532,7 @@ namespace OpenTelemetry.Instrumentation.AspNetCore.Tests
Assert.NotNull(baggageCountAfterStart);
Assert.Equal(2, baggageCountAfterStart);
Assert.NotNull(baggageCountAfterStop);
Assert.Equal(0, baggageCountAfterStop);
Assert.Equal(2, baggageCountAfterStop);
}
[Theory]