[release/9.0-staging] Remove HttpMetricsEnrichmentContext caching by github-actions[bot] · Pull Request #110626 · dotnet/runtime
Backport of #110580 to release/9.0-staging
Fixed in #108284
/cc @MihaZupan
Customer Impact
Reported by 6 customers in the issue #108284.
HttpMetricsEnrichmentContext is a feature added in .NET 8.0 that allows the user to provide extra information during HTTP metrics collection.
A bug in the implementation results in certain valid usage patterns, such as request retries (e.g. using Polly), to corrupt global state, leading to reliability issues for the remainder of the process lifetime.
The user may experience corrupted (e.g. missing or duplicate) metrics information, and their requests may randomly fail with unforseen exceptions (NullReferenceException, InvalidOperationExceptions).
Regression
No - The issue was present in the initial implementation of the new feature in .NET 8.0.
Testing
Targeted tests were added that exercise the impacted scenario where request objects are reused.
Risk
Low.
The change is limited to the HttpMetricsEnrichmentContext type and thus the impact is limited to uses of this feature.
Without the fixes, the feature is already unreliable in common usage scenarios (e.g. using Polly for request retries).