Skip to content
Merged
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
15 changes: 11 additions & 4 deletions tests/integrations/aiohttp/test_aiohttp.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import pytest

from aiohttp import web, ClientSession
from aiohttp import web
from aiohttp.client import ServerDisconnectedError
from aiohttp.web_request import Request
from aiohttp.web_exceptions import (
Expand Down Expand Up @@ -636,6 +636,7 @@ async def handler(request):
@pytest.mark.asyncio
async def test_span_origin(
sentry_init,
aiohttp_raw_server,
aiohttp_client,
capture_events,
):
Expand All @@ -644,10 +645,16 @@ async def test_span_origin(
traces_sample_rate=1.0,
)

# server for making span request
async def handler(request):
return web.Response(text="OK")

raw_server = await aiohttp_raw_server(handler)

async def hello(request):
async with ClientSession() as session:
async with session.get("http://example.com"):
return web.Response(text="hello")
span_client = await aiohttp_client(raw_server)
await span_client.get("/")
return web.Response(text="hello")

app = web.Application()
app.router.add_get(r"/", hello)
Expand Down
8 changes: 4 additions & 4 deletions tests/integrations/stdlib/test_httplib.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ def test_empty_realurl(sentry_init):
"""

sentry_init(dsn="")
HTTPConnection("example.com", port=443).putrequest("POST", None)
HTTPConnection("localhost", port=PORT).putrequest("POST", None)


def test_httplib_misuse(sentry_init, capture_events, request):
Expand Down Expand Up @@ -379,7 +379,7 @@ def test_span_origin(sentry_init, capture_events):
events = capture_events()

with start_transaction(name="foo"):
conn = HTTPConnection("example.com")
conn = HTTPConnection("localhost", port=PORT)
conn.request("GET", "/foo")
conn.getresponse()

Expand All @@ -400,7 +400,7 @@ def test_http_timeout(monkeypatch, sentry_init, capture_envelopes):

with pytest.raises(TimeoutError):
with start_transaction(op="op", name="name"):
conn = HTTPSConnection("www.example.com")
conn = HTTPConnection("localhost", port=PORT)
conn.request("GET", "/bla")
conn.getresponse()

Expand All @@ -410,4 +410,4 @@ def test_http_timeout(monkeypatch, sentry_init, capture_envelopes):

span = transaction["spans"][0]
assert span["op"] == "http.client"
assert span["description"] == "GET https://www.example.com/bla"
assert span["description"] == f"GET http://localhost:{PORT}/bla" # noqa: E231
Loading