Skip to content

Commit

Permalink
trying something with httpx
Browse files Browse the repository at this point in the history
  • Loading branch information
sentrivana committed Jan 17, 2025
1 parent 5b9da4b commit 10f96a7
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
1 change: 1 addition & 0 deletions scripts/populate_tox/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
jinja2
packaging
requests
sentry_sdk
22 changes: 17 additions & 5 deletions tests/integrations/httpx/test_httpx.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
from tests.conftest import ApproxDict


timeout = httpx.Timeout(10.0, read_timeout=None)


@pytest.mark.parametrize(
"httpx_client",
(httpx.Client(), httpx.AsyncClient()),
Expand All @@ -31,7 +34,7 @@ def before_breadcrumb(crumb, hint):

if asyncio.iscoroutinefunction(httpx_client.get):
response = asyncio.get_event_loop().run_until_complete(
httpx_client.get(url)
httpx_client.get(url, timeout=timeout, verify=False)
)
else:
response = httpx_client.get(url)
Expand Down Expand Up @@ -74,7 +77,7 @@ def test_outgoing_trace_headers(sentry_init, httpx_client):
) as transaction:
if asyncio.iscoroutinefunction(httpx_client.get):
response = asyncio.get_event_loop().run_until_complete(
httpx_client.get(url)
httpx_client.get(url, timeout=timeout, verify=False)
)
else:
response = httpx_client.get(url)
Expand Down Expand Up @@ -110,7 +113,12 @@ def test_outgoing_trace_headers_append_to_baggage(sentry_init, httpx_client):
) as transaction:
if asyncio.iscoroutinefunction(httpx_client.get):
response = asyncio.get_event_loop().run_until_complete(
httpx_client.get(url, headers={"baGGage": "custom=data"})
httpx_client.get(
url,
headers={"baGGage": "custom=data"},
timeout=timeout,
verify=False,
)
)
else:
response = httpx_client.get(url, headers={"baGGage": "custom=data"})
Expand Down Expand Up @@ -261,7 +269,9 @@ def test_option_trace_propagation_targets(

with sentry_sdk.start_transaction(): # Must be in a transaction to propagate headers
if asyncio.iscoroutinefunction(httpx_client.get):
asyncio.get_event_loop().run_until_complete(httpx_client.get(url))
asyncio.get_event_loop().run_until_complete(
httpx_client.get(url, timeout=timeout, verify=False)
)
else:
httpx_client.get(url)

Expand Down Expand Up @@ -339,7 +349,9 @@ def test_span_origin(sentry_init, capture_events, httpx_client):

with start_transaction(name="test_transaction"):
if asyncio.iscoroutinefunction(httpx_client.get):
asyncio.get_event_loop().run_until_complete(httpx_client.get(url))
asyncio.get_event_loop().run_until_complete(
httpx_client.get(url, timeout=timeout, verify=False)
)
else:
httpx_client.get(url)

Expand Down

0 comments on commit 10f96a7

Please sign in to comment.