Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions sentry_sdk/integrations/boto3.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ def _sentry_request_created(
is_span_streaming_enabled = has_span_streaming_enabled(client.options)
span: "Union[Span, StreamedSpan]"
if is_span_streaming_enabled:
if sentry_sdk.traces.get_current_span() is None:
return
span = sentry_sdk.traces.start_span(
name=description,
attributes={
Expand Down
6 changes: 6 additions & 0 deletions sentry_sdk/integrations/httpx.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,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 real_send(self, request, **kwargs)

Check warning on line 64 in sentry_sdk/integrations/httpx.py

View check run for this annotation

@sentry/warden / warden: code-review

Early return skips trace propagation headers on outgoing requests in streaming path

When span streaming is enabled and there is no current span, the new guard returns `real_send(...)` early, bypassing the `should_propagate_trace` block that injects `sentry-trace`/`baggage` headers. Because `Scope.iter_trace_propagation_headers()` falls back to the active propagation context when no span exists (the `else: get_active_propagation_context().iter_headers()` branch), outgoing requests previously still received trace headers even without an active span. After this change, distributed trace propagation is silently dropped for these requests in streaming mode — was dropping propagation intended, or only the child-span creation? This same pattern is repeated across the affected integrations (httpx, httpx2, pyreqwest, boto3, stdlib) and their sync/async send paths.

Check warning on line 64 in sentry_sdk/integrations/httpx.py

View check run for this annotation

@sentry/warden / warden: find-bugs

[WQX-JYJ] Early return in streaming path drops outgoing trace propagation headers (additional location)

In the async httpx2 `send` wrapper, when span streaming is enabled and `sentry_sdk.traces.get_current_span()` is `None`, the new guard does `return await real_send(...)`, bypassing the entire span block including the `should_propagate_trace(...)` / `iter_trace_propagation_headers()` header injection. Because `Scope.iter_trace_propagation_headers` falls back to `get_active_propagation_context().iter_headers()` when no span is present, trace headers would normally still be generated. The early return therefore sends outgoing requests with no `sentry-trace`/`baggage` headers, breaking distributed trace propagation. The same early-return pattern applies in `stdlib.py` (`return real_putrequest(...)` at line 117). Notably, `pyreqwest.py` in this same PR handles the no-span case differently (using `nullcontext()`) so that propagation headers are still injected, showing the intended behavior and the inconsistency.

with sentry_sdk.traces.start_span(
name="%s %s"
% (
Expand Down Expand Up @@ -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/httpx.py

View check run for this annotation

@sentry/warden / warden: code-review

[WJX-9E5] Early return skips trace propagation headers on outgoing requests in streaming path (additional location)

When span streaming is enabled and there is no current span, the new guard returns `real_send(...)` early, bypassing the `should_propagate_trace` block that injects `sentry-trace`/`baggage` headers. Because `Scope.iter_trace_propagation_headers()` falls back to the active propagation context when no span exists (the `else: get_active_propagation_context().iter_headers()` branch), outgoing requests previously still received trace headers even without an active span. After this change, distributed trace propagation is silently dropped for these requests in streaming mode — was dropping propagation intended, or only the child-span creation? This same pattern is repeated across the affected integrations (httpx, httpx2, pyreqwest, boto3, stdlib) and their sync/async send paths.

Check warning on line 178 in sentry_sdk/integrations/httpx.py

View check run for this annotation

@sentry/warden / warden: find-bugs

Early return in streaming path drops outgoing trace propagation headers

In the async httpx2 `send` wrapper, when span streaming is enabled and `sentry_sdk.traces.get_current_span()` is `None`, the new guard does `return await real_send(...)`, bypassing the entire span block including the `should_propagate_trace(...)` / `iter_trace_propagation_headers()` header injection. Because `Scope.iter_trace_propagation_headers` falls back to `get_active_propagation_context().iter_headers()` when no span is present, trace headers would normally still be generated. The early return therefore sends outgoing requests with no `sentry-trace`/`baggage` headers, breaking distributed trace propagation. The same early-return pattern applies in `stdlib.py` (`return real_putrequest(...)` at line 117). Notably, `pyreqwest.py` in this same PR handles the no-span case differently (using `nullcontext()`) so that propagation headers are still injected, showing the intended behavior and the inconsistency.
Comment on lines +176 to +178

Copy link
Copy Markdown
Contributor

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_headers block, so outgoing HTTP requests get no sentry-trace/baggage headers when span streaming is enabled and there is no current span, breaking distributed trace continuation.

Evidence
  • iter_trace_propagation_headers in scope.py (lines 703-716) yields headers from get_active_propagation_context().iter_headers() even when span is None, so propagation does not require an active span.
  • In the async send, the added if sentry_sdk.traces.get_current_span() is None: return await real_send(...) runs before the if should_propagate_trace(client, str(request.url)) header-injection block.
  • Result: no sentry-trace/baggage headers are added to the outgoing request in that branch, whereas the non-streaming else branch always injects them.
  • The same pattern appears in stdlib.py putrequest, where the guard returns before the should_propagate_trace loop that calls self.putheader(key, value).
Also found at 5 additional locations
  • sentry_sdk/integrations/httpx2.py:63-64
  • sentry_sdk/integrations/httpx.py:63-65
  • sentry_sdk/integrations/httpx2.py:176-178
  • sentry_sdk/integrations/stdlib.py:117-118
  • sentry_sdk/integrations/stdlib.py:309-310

Identified by Warden find-bugs · YUR-XRB

with sentry_sdk.traces.start_span(
name="%s %s"
% (
Expand Down
6 changes: 6 additions & 0 deletions sentry_sdk/integrations/httpx2.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

View check run for this annotation

@sentry/warden / warden: find-bugs

[WQX-JYJ] Early return in streaming path drops outgoing trace propagation headers (additional location)

In the async httpx2 `send` wrapper, when span streaming is enabled and `sentry_sdk.traces.get_current_span()` is `None`, the new guard does `return await real_send(...)`, bypassing the entire span block including the `should_propagate_trace(...)` / `iter_trace_propagation_headers()` header injection. Because `Scope.iter_trace_propagation_headers` falls back to `get_active_propagation_context().iter_headers()` when no span is present, trace headers would normally still be generated. The early return therefore sends outgoing requests with no `sentry-trace`/`baggage` headers, breaking distributed trace propagation. The same early-return pattern applies in `stdlib.py` (`return real_putrequest(...)` at line 117). Notably, `pyreqwest.py` in this same PR handles the no-span case differently (using `nullcontext()`) so that propagation headers are still injected, showing the intended behavior and the inconsistency.
return real_send(self, request, **kwargs)

Check warning on line 64 in sentry_sdk/integrations/httpx2.py

View check run for this annotation

@sentry/warden / warden: code-review

[WJX-9E5] Early return skips trace propagation headers on outgoing requests in streaming path (additional location)

When span streaming is enabled and there is no current span, the new guard returns `real_send(...)` early, bypassing the `should_propagate_trace` block that injects `sentry-trace`/`baggage` headers. Because `Scope.iter_trace_propagation_headers()` falls back to the active propagation context when no span exists (the `else: get_active_propagation_context().iter_headers()` branch), outgoing requests previously still received trace headers even without an active span. After this change, distributed trace propagation is silently dropped for these requests in streaming mode — was dropping propagation intended, or only the child-span creation? This same pattern is repeated across the affected integrations (httpx, httpx2, pyreqwest, boto3, stdlib) and their sync/async send paths.
Comment on lines +63 to +64

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The 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 real_send() early bypasses should_propagate_trace and header injection, so sentry-trace/baggage headers are no longer added to outgoing requests. This breaks distributed tracing continuity: an incoming/continued trace's propagation context would no longer be forwarded downstream when no span is active, whereas the non-streaming branch always propagates. The change intended only to avoid creating orphan root segments, but it also drops header propagation as a side effect. Consider still injecting propagation headers before returning early.

Evidence
  • In _install_httpx_client.send (httpx.py:62-64) the new guard if sentry_sdk.traces.get_current_span() is None: return real_send(...) returns before the with start_span block, which is the only place in the streaming path that calls should_propagate_trace and writes sentry-trace/baggage headers.
  • Scope.iter_trace_propagation_headers (scope.py:698-716) falls back to get_active_propagation_context().iter_headers() when no span is present, so propagation headers are normally emitted even with no active span.
  • The non-streaming else branch (httpx.py) always runs should_propagate_trace + header injection, so skipping it in streaming mode is an asymmetric behavioral regression.
  • The same pattern was added to the async client (httpx.py) and to httpx2/boto3/pyreqwest/stdlib, so the propagation gap applies to all patched HTTP clients.
Also found at 4 additional locations
  • sentry_sdk/integrations/httpx.py:176-178
  • sentry_sdk/integrations/httpx.py:63-64
  • sentry_sdk/integrations/httpx2.py:176-178
  • sentry_sdk/integrations/stdlib.py:308-310

Identified by Warden code-review · FFE-WY6


with sentry_sdk.traces.start_span(
name="%s %s"
% (
Expand Down Expand Up @@ -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

View check run for this annotation

@sentry/warden / warden: code-review

[WJX-9E5] Early return skips trace propagation headers on outgoing requests in streaming path (additional location)

When span streaming is enabled and there is no current span, the new guard returns `real_send(...)` early, bypassing the `should_propagate_trace` block that injects `sentry-trace`/`baggage` headers. Because `Scope.iter_trace_propagation_headers()` falls back to the active propagation context when no span exists (the `else: get_active_propagation_context().iter_headers()` branch), outgoing requests previously still received trace headers even without an active span. After this change, distributed trace propagation is silently dropped for these requests in streaming mode — was dropping propagation intended, or only the child-span creation? This same pattern is repeated across the affected integrations (httpx, httpx2, pyreqwest, boto3, stdlib) and their sync/async send paths.

Check warning on line 178 in sentry_sdk/integrations/httpx2.py

View check run for this annotation

@sentry/warden / warden: find-bugs

[WQX-JYJ] Early return in streaming path drops outgoing trace propagation headers (additional location)

In the async httpx2 `send` wrapper, when span streaming is enabled and `sentry_sdk.traces.get_current_span()` is `None`, the new guard does `return await real_send(...)`, bypassing the entire span block including the `should_propagate_trace(...)` / `iter_trace_propagation_headers()` header injection. Because `Scope.iter_trace_propagation_headers` falls back to `get_active_propagation_context().iter_headers()` when no span is present, trace headers would normally still be generated. The early return therefore sends outgoing requests with no `sentry-trace`/`baggage` headers, breaking distributed trace propagation. The same early-return pattern applies in `stdlib.py` (`return real_putrequest(...)` at line 117). Notably, `pyreqwest.py` in this same PR handles the no-span case differently (using `nullcontext()`) so that propagation headers are still injected, showing the intended behavior and the inconsistency.
with sentry_sdk.traces.start_span(
name="%s %s"
% (
Expand Down
38 changes: 22 additions & 16 deletions sentry_sdk/integrations/pyreqwest.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
SENSITIVE_DATA_SUBSTITUTE,
capture_internal_exceptions,
logger,
nullcontext,
parse_url,
)

Expand Down Expand Up @@ -88,18 +89,22 @@ def _sentry_pyreqwest_span(request: "Request") -> "Generator[Any, None, None]":

span_streaming = has_span_streaming_enabled(sentry_sdk.get_client().options)
if span_streaming:
with sentry_sdk.traces.start_span(
name=f"{request.method} {parsed_url.url if parsed_url else SENSITIVE_DATA_SUBSTITUTE}",
attributes={
"sentry.op": OP.HTTP_CLIENT,
"sentry.origin": PyreqwestIntegration.origin,
SPANDATA.HTTP_REQUEST_METHOD: request.method,
},
) as span:
if parsed_url is not None and should_send_default_pii():
span.set_attribute(SPANDATA.URL_FULL, parsed_url.url)
span.set_attribute(SPANDATA.URL_QUERY, parsed_url.query)
span.set_attribute(SPANDATA.URL_FRAGMENT, parsed_url.fragment)
span_ctx = nullcontext()
if sentry_sdk.traces.get_current_span() is not None:
span_ctx = sentry_sdk.traces.start_span(
name=f"{request.method} {parsed_url.url if parsed_url else SENSITIVE_DATA_SUBSTITUTE}",
attributes={
"sentry.op": OP.HTTP_CLIENT,
"sentry.origin": PyreqwestIntegration.origin,
SPANDATA.HTTP_REQUEST_METHOD: request.method,
},
)
with span_ctx as span:
if span is not None:
if parsed_url is not None and should_send_default_pii():
span.set_attribute(SPANDATA.URL_FULL, parsed_url.url)
span.set_attribute(SPANDATA.URL_QUERY, parsed_url.query)
span.set_attribute(SPANDATA.URL_FRAGMENT, parsed_url.fragment)

if should_propagate_trace(sentry_sdk.get_client(), str(request.url)):
for (
Expand All @@ -119,8 +124,9 @@ def _sentry_pyreqwest_span(request: "Request") -> "Generator[Any, None, None]":

yield span

with capture_internal_exceptions():
add_http_request_source(span)
if span is not None:
with capture_internal_exceptions():
add_http_request_source(span)

return

Expand Down Expand Up @@ -171,7 +177,7 @@ async def sentry_async_middleware(
SPANDATA.HTTP_STATUS_CODE,
response.status,
)
else:
elif span is not None:
span.set_http_status(response.status)

return response
Expand All @@ -191,7 +197,7 @@ def sentry_sync_middleware(
SPANDATA.HTTP_STATUS_CODE,
response.status,
)
else:
elif span is not None:
span.set_http_status(response.status)

return response
10 changes: 10 additions & 0 deletions sentry_sdk/integrations/stdlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,9 @@
span_streaming = has_span_streaming_enabled(client.options)
span: "Union[Span, StreamedSpan]"
if span_streaming:
if sentry_sdk.traces.get_current_span() is None:
return real_putrequest(self, method, url, *args, **kwargs)

Check warning on line 118 in sentry_sdk/integrations/stdlib.py

View check run for this annotation

@sentry/warden / warden: code-review

[WJX-9E5] Early return skips trace propagation headers on outgoing requests in streaming path (additional location)

When span streaming is enabled and there is no current span, the new guard returns `real_send(...)` early, bypassing the `should_propagate_trace` block that injects `sentry-trace`/`baggage` headers. Because `Scope.iter_trace_propagation_headers()` falls back to the active propagation context when no span exists (the `else: get_active_propagation_context().iter_headers()` branch), outgoing requests previously still received trace headers even without an active span. After this change, distributed trace propagation is silently dropped for these requests in streaming mode — was dropping propagation intended, or only the child-span creation? This same pattern is repeated across the affected integrations (httpx, httpx2, pyreqwest, boto3, stdlib) and their sync/async send paths.

Check warning on line 118 in sentry_sdk/integrations/stdlib.py

View check run for this annotation

@sentry/warden / warden: find-bugs

[WQX-JYJ] Early return in streaming path drops outgoing trace propagation headers (additional location)

In the async httpx2 `send` wrapper, when span streaming is enabled and `sentry_sdk.traces.get_current_span()` is `None`, the new guard does `return await real_send(...)`, bypassing the entire span block including the `should_propagate_trace(...)` / `iter_trace_propagation_headers()` header injection. Because `Scope.iter_trace_propagation_headers` falls back to `get_active_propagation_context().iter_headers()` when no span is present, trace headers would normally still be generated. The early return therefore sends outgoing requests with no `sentry-trace`/`baggage` headers, breaking distributed trace propagation. The same early-return pattern applies in `stdlib.py` (`return real_putrequest(...)` at line 117). Notably, `pyreqwest.py` in this same PR handles the no-span case differently (using `nullcontext()`) so that propagation headers are still injected, showing the intended behavior and the inconsistency.

span = sentry_sdk.traces.start_span(
name="%s %s"
% (method, parsed_url.url if parsed_url else SENSITIVE_DATA_SUBSTITUTE),
Expand Down Expand Up @@ -303,6 +306,9 @@
span_streaming = has_span_streaming_enabled(sentry_sdk.get_client().options)
span: "Union[Span, StreamedSpan]"
if span_streaming:
if sentry_sdk.traces.get_current_span() is None:
return old_popen_init(self, *a, **kw)

Check warning on line 310 in sentry_sdk/integrations/stdlib.py

View check run for this annotation

@sentry/warden / warden: code-review

[WJX-9E5] Early return skips trace propagation headers on outgoing requests in streaming path (additional location)

When span streaming is enabled and there is no current span, the new guard returns `real_send(...)` early, bypassing the `should_propagate_trace` block that injects `sentry-trace`/`baggage` headers. Because `Scope.iter_trace_propagation_headers()` falls back to the active propagation context when no span exists (the `else: get_active_propagation_context().iter_headers()` branch), outgoing requests previously still received trace headers even without an active span. After this change, distributed trace propagation is silently dropped for these requests in streaming mode — was dropping propagation intended, or only the child-span creation? This same pattern is repeated across the affected integrations (httpx, httpx2, pyreqwest, boto3, stdlib) and their sync/async send paths.

span = sentry_sdk.traces.start_span(
name=description,
attributes={
Expand Down Expand Up @@ -353,6 +359,8 @@
) -> "Any":
span_streaming = has_span_streaming_enabled(sentry_sdk.get_client().options)
if span_streaming:
if sentry_sdk.traces.get_current_span() is None:
return old_popen_wait(self, *a, **kw)
with sentry_sdk.traces.start_span(
name=OP.SUBPROCESS_WAIT,
attributes={
Expand Down Expand Up @@ -380,6 +388,8 @@
) -> "Any":
span_streaming = has_span_streaming_enabled(sentry_sdk.get_client().options)
if span_streaming:
if sentry_sdk.traces.get_current_span() is None:
return old_popen_communicate(self, *a, **kw)
with sentry_sdk.traces.start_span(
name=OP.SUBPROCESS_COMMUNICATE,
attributes={
Expand Down
116 changes: 64 additions & 52 deletions tests/integrations/httpx2/test_httpx2.py
Original file line number Diff line number Diff line change
Expand Up @@ -733,10 +733,11 @@ def test_outgoing_trace_headers_span_streaming(

items = capture_items("span")

if asyncio.iscoroutinefunction(httpx2_client.get):
response = asyncio.run(httpx2_client.get(url))
else:
response = httpx2_client.get(url)
with sentry_sdk.traces.start_span(name="test"):
if asyncio.iscoroutinefunction(httpx2_client.get):
response = asyncio.run(httpx2_client.get(url))
else:
response = httpx2_client.get(url)

sentry_sdk.flush()

Expand Down Expand Up @@ -775,12 +776,13 @@ def test_outgoing_trace_headers_append_to_baggage_span_streaming(
items = capture_items("span")

with mock.patch("sentry_sdk.tracing_utils.Random.randrange", return_value=500000):
if asyncio.iscoroutinefunction(httpx2_client.get):
response = asyncio.run(
httpx2_client.get(url, headers={"baGGage": "custom=data"})
)
else:
response = httpx2_client.get(url, headers={"baGGage": "custom=data"})
with sentry_sdk.traces.start_span(name="test"):
if asyncio.iscoroutinefunction(httpx2_client.get):
response = asyncio.run(
httpx2_client.get(url, headers={"baGGage": "custom=data"})
)
else:
response = httpx2_client.get(url, headers={"baGGage": "custom=data"})

sentry_sdk.flush()

Expand Down Expand Up @@ -814,10 +816,11 @@ def test_request_source_disabled_span_streaming(

url = "http://example.com/"

if asyncio.iscoroutinefunction(httpx2_client.get):
asyncio.run(httpx2_client.get(url))
else:
httpx2_client.get(url)
with sentry_sdk.traces.start_span(name="test"):
if asyncio.iscoroutinefunction(httpx2_client.get):
asyncio.run(httpx2_client.get(url))
else:
httpx2_client.get(url)

sentry_sdk.flush()

Expand Down Expand Up @@ -858,10 +861,11 @@ def test_request_source_enabled_span_streaming(

url = "http://example.com/"

if asyncio.iscoroutinefunction(httpx2_client.get):
asyncio.run(httpx2_client.get(url))
else:
httpx2_client.get(url)
with sentry_sdk.traces.start_span(name="test"):
if asyncio.iscoroutinefunction(httpx2_client.get):
asyncio.run(httpx2_client.get(url))
else:
httpx2_client.get(url)

sentry_sdk.flush()

Expand Down Expand Up @@ -894,10 +898,11 @@ def test_request_source_span_streaming(

url = "http://example.com/"

if asyncio.iscoroutinefunction(httpx2_client.get):
asyncio.run(httpx2_client.get(url))
else:
httpx2_client.get(url)
with sentry_sdk.traces.start_span(name="test"):
if asyncio.iscoroutinefunction(httpx2_client.get):
asyncio.run(httpx2_client.get(url))
else:
httpx2_client.get(url)

sentry_sdk.flush()

Expand Down Expand Up @@ -951,14 +956,15 @@ def test_request_source_with_module_in_search_path_span_streaming(

url = "http://example.com/"

if asyncio.iscoroutinefunction(httpx2_client.get):
from httpx2_helpers.helpers import async_get_request_with_client
with sentry_sdk.traces.start_span(name="test"):
if asyncio.iscoroutinefunction(httpx2_client.get):
from httpx2_helpers.helpers import async_get_request_with_client

asyncio.run(async_get_request_with_client(httpx2_client, url))
else:
from httpx2_helpers.helpers import get_request_with_client
asyncio.run(async_get_request_with_client(httpx2_client, url))
else:
from httpx2_helpers.helpers import get_request_with_client

get_request_with_client(httpx2_client, url)
get_request_with_client(httpx2_client, url)

sentry_sdk.flush()

Expand Down Expand Up @@ -1010,10 +1016,11 @@ def test_no_request_source_if_duration_too_short_span_streaming(

url = "http://example.com/"

if asyncio.iscoroutinefunction(httpx2_client.get):
asyncio.run(httpx2_client.get(url))
else:
httpx2_client.get(url)
with sentry_sdk.traces.start_span(name="test"):
if asyncio.iscoroutinefunction(httpx2_client.get):
asyncio.run(httpx2_client.get(url))
else:
httpx2_client.get(url)

sentry_sdk.flush()

Expand Down Expand Up @@ -1047,10 +1054,11 @@ def test_request_source_if_duration_over_threshold_span_streaming(

url = "http://example.com/"

if asyncio.iscoroutinefunction(httpx2_client.get):
asyncio.run(httpx2_client.get(url))
else:
httpx2_client.get(url)
with sentry_sdk.traces.start_span(name="test"):
if asyncio.iscoroutinefunction(httpx2_client.get):
asyncio.run(httpx2_client.get(url))
else:
httpx2_client.get(url)

sentry_sdk.flush()

Expand Down Expand Up @@ -1099,10 +1107,11 @@ def test_span_origin_span_streaming(

url = "http://example.com/"

if asyncio.iscoroutinefunction(httpx2_client.get):
asyncio.run(httpx2_client.get(url))
else:
httpx2_client.get(url)
with sentry_sdk.traces.start_span(name="test"):
if asyncio.iscoroutinefunction(httpx2_client.get):
asyncio.run(httpx2_client.get(url))
else:
httpx2_client.get(url)

sentry_sdk.flush()

Expand Down Expand Up @@ -1131,10 +1140,11 @@ def test_http_url_attributes_span_streaming(

url = "http://example.com/?foo=bar#frag"

if asyncio.iscoroutinefunction(httpx2_client.get):
asyncio.run(httpx2_client.get(url))
else:
httpx2_client.get(url)
with sentry_sdk.traces.start_span(name="test"):
if asyncio.iscoroutinefunction(httpx2_client.get):
asyncio.run(httpx2_client.get(url))
else:
httpx2_client.get(url)

sentry_sdk.flush()

Expand Down Expand Up @@ -1167,10 +1177,11 @@ def test_http_url_attributes_no_query_or_fragment_span_streaming(

url = "http://example.com/"

if asyncio.iscoroutinefunction(httpx2_client.get):
asyncio.run(httpx2_client.get(url))
else:
httpx2_client.get(url)
with sentry_sdk.traces.start_span(name="test"):
if asyncio.iscoroutinefunction(httpx2_client.get):
asyncio.run(httpx2_client.get(url))
else:
httpx2_client.get(url)

sentry_sdk.flush()

Expand Down Expand Up @@ -1202,10 +1213,11 @@ def test_http_url_attributes_pii_disabled_span_streaming(

url = "http://example.com/?foo=bar#frag"

if asyncio.iscoroutinefunction(httpx2_client.get):
asyncio.run(httpx2_client.get(url))
else:
httpx2_client.get(url)
with sentry_sdk.traces.start_span(name="test"):
if asyncio.iscoroutinefunction(httpx2_client.get):
asyncio.run(httpx2_client.get(url))
else:
httpx2_client.get(url)

sentry_sdk.flush()

Expand Down
Loading
Loading