-
Notifications
You must be signed in to change notification settings - Fork 638
fix(tracing): Skip child span creation in streaming path when no current span (HTTP clients) #6811
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -58,8 +58,11 @@ | |
| parsed_url = None | ||
| with capture_internal_exceptions(): | ||
| parsed_url = parse_url(str(request.url), sanitize=False) | ||
|
|
||
| if is_span_streaming_enabled: | ||
| if sentry_sdk.traces.get_current_span() is None: | ||
|
Check warning on line 63 in sentry_sdk/integrations/httpx2.py
|
||
| return real_send(self, request, **kwargs) | ||
|
Check warning on line 64 in sentry_sdk/integrations/httpx2.py
|
||
|
Comment on lines
+63
to
+64
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Early return skips trace propagation headers on outgoing requests in streaming mode When streaming is enabled and there is no current span, returning Evidence
Also found at 4 additional locations
Identified by Warden code-review · FFE-WY6 |
||
|
|
||
| with sentry_sdk.traces.start_span( | ||
| name="%s %s" | ||
| % ( | ||
|
|
@@ -170,6 +173,9 @@ | |
| parsed_url = parse_url(str(request.url), sanitize=False) | ||
|
|
||
| if is_span_streaming_enabled: | ||
| if sentry_sdk.traces.get_current_span() is None: | ||
| return await real_send(self, request, **kwargs) | ||
|
|
||
|
Check warning on line 178 in sentry_sdk/integrations/httpx2.py
|
||
| with sentry_sdk.traces.start_span( | ||
| name="%s %s" | ||
| % ( | ||
|
|
||
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.
Trace propagation headers dropped when no current span in streaming path
This early return bypasses the
should_propagate_trace/iter_trace_propagation_headersblock, so outgoing HTTP requests get nosentry-trace/baggageheaders when span streaming is enabled and there is no current span, breaking distributed trace continuation.Evidence
iter_trace_propagation_headersinscope.py(lines 703-716) yields headers fromget_active_propagation_context().iter_headers()even whenspan is None, so propagation does not require an active span.send, the addedif sentry_sdk.traces.get_current_span() is None: return await real_send(...)runs before theif should_propagate_trace(client, str(request.url))header-injection block.sentry-trace/baggageheaders are added to the outgoing request in that branch, whereas the non-streamingelsebranch always injects them.stdlib.pyputrequest, where the guard returns before theshould_propagate_traceloop that callsself.putheader(key, value).Also found at 5 additional locations
sentry_sdk/integrations/httpx2.py:63-64sentry_sdk/integrations/httpx.py:63-65sentry_sdk/integrations/httpx2.py:176-178sentry_sdk/integrations/stdlib.py:117-118sentry_sdk/integrations/stdlib.py:309-310Identified by Warden find-bugs · YUR-XRB