-
-
Notifications
You must be signed in to change notification settings - Fork 226
fix: http integration uses correct parent span id #4264
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
21c7fc1
use correct parent span in http
bruno-garcia 0233ca2
test
bruno-garcia 18fae46
changelog
bruno-garcia 4655627
release: 5.11.0-alpha.1
getsentry-bot 20fa9b7
Merge branch 'release/5.11.0-alpha.1' into fix/http-parent-span
59fb4e8
Update CHANGELOG.md
bruno-garcia File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This shouldn't be necessary. The previous behaviour simply got the header from
_hub.GetTraceHeader(), which should be reading it off the current span.This seems like a workaround for the fact that the span representing the HttpRequest hasn't been set correctly as the current span then.
Just looking at the code, I can't see why that would be. All of the machinery to make this happen seems to be in place.
Basically the HttpMessageHandler creates the span here:
sentry-dotnet/src/Sentry/SentryHttpMessageHandler.cs
Lines 70 to 73 in dc3c0dd
And the new span gets pushed onto the stack to become the active span here:
sentry-dotnet/src/Sentry/TransactionTracer.cs
Lines 311 to 312 in aebd6a2
If you've got the code sample that results in the erroneous parent/child relationship, it'd be good to dig into this to try to work out what's going wrong with the active span tracking.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we don't want the http as current span. because otherwise any other span in parallel becomes a child of the http one. I saw this behavior before and it was broken
the whole thing when using MAUI (or any global mode approach) is totally broken, with this I was able to set a span explicitly and have the parent child work properly for outgoing http regardless of what's explicitly set to the scope (see scope.Span)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to summarise a chat that @bruno-garcia and I had...
The issue with not wanting the spans for outgoing HttpRequests to be mixed up with other spans (perhaps being performed in async Tasks) is a bit more nuanced.
Currently, the way the MessageHandler creates spans is this:
sentry-dotnet/src/Sentry/SentryHttpMessageHandler.cs
Lines 68 to 73 in dc3c0dd
In the most common case then, if there's no
Scope.Transactionthen no span gets created. If there is aScope.Transactionthen a span gets created as a child of the transaction... and implicitly it becomes the "last active span" for the transaction.The way Bruno managed to work around that in the symbol collector is by setting
Scope.Span(notScope.Transaction):https://github.com/getsentry/symbol-collector/blob/8a0fdb2594c3028f63f180b9b56b1efea1cbce34/src/SymbolCollector.Core/Client.cs#L75
This appears to be completely undocumented.