[release/9.0-staging] Remove HttpMetricsEnrichmentContext caching #110626
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
,InvalidOperationException
s).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).