Dynamic Sampling Context propagates correctly for HttpClient spans #3208
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.
Resolves #3187
Propagate context after creating HttpClient request spans
The primary cause of the problem appears to be because we set the outbound trace headers before we create the span that represents the outgoing HttpRequest both here:
sentry-dotnet/src/Sentry/SentryMessageHandler.cs
Lines 85 to 86 in 24c159f
And here:
sentry-dotnet/src/Sentry/SentryMessageHandler.cs
Lines 107 to 108 in 24c159f
Propagate context for SpanTracers as well as TransactionTracers
There's a secondary problem however with the
Hub.GetBaggage
method:sentry-dotnet/src/Sentry/Internal/Hub.cs
Lines 215 to 224 in ee3ea36
This works when the current span is a TransactionTracer... in that case the DSC is read correctly from the current span and it looks like this:
On the other hand, when the current span is a
SpanTracer
thenGetOrCreateDynamicSamplingContext
is called using the propagation context from the current scope, which does not contain a DSC... so a new one gets created, which looks like this:It's got a release and an environment, but not a sample rate.
@bitsandfoxes I think the solution I've come up with for this makes sense, but would be good to get your eyes on it. I'm not sure I understand what the purpose of the default/fallback is and why this has a release/environment but not a sample rate.