Skip to content

Commit be6fb85

Browse files
Fix aiohttp client (#733)
Co-authored-by: Colton Myers <[email protected]>
1 parent be70691 commit be6fb85

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

elasticapm/instrumentation/packages/asyncio/aiohttp_client.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ class AioHttpClientInstrumentation(AsyncAbstractInstrumentedModule):
4444
async def call(self, module, method, wrapped, instance, args, kwargs):
4545
method = kwargs["method"] if "method" in kwargs else args[0]
4646
url = kwargs["url"] if "url" in kwargs else args[1]
47+
url = str(url)
4748

4849
signature = " ".join([method.upper(), get_host_from_url(url)])
4950
url = sanitize_url(url)

tests/instrumentation/asyncio/aiohttp_client_tests.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,17 +31,22 @@
3131
import pytest # isort:skip
3232

3333
aiohttp = pytest.importorskip("aiohttp") # isort:skip
34+
yarl = pytest.importorskip("yarl") # isort:skip
3435

3536
from elasticapm.conf import constants
3637
from elasticapm.utils.disttracing import TraceParent
3738

3839
pytestmark = [pytest.mark.asyncio, pytest.mark.aiohttp]
3940

4041

41-
async def test_http_get(instrument, event_loop, elasticapm_client, waiting_httpserver):
42+
@pytest.mark.parametrize("use_yarl", [True, False])
43+
async def test_http_get(instrument, event_loop, elasticapm_client, waiting_httpserver, use_yarl):
4244
assert event_loop.is_running()
4345
elasticapm_client.begin_transaction("test")
4446

47+
url = waiting_httpserver.url
48+
url = yarl.URL(url) if use_yarl else url
49+
4550
async with aiohttp.ClientSession() as session:
4651
async with session.get(waiting_httpserver.url) as resp:
4752
status = resp.status

0 commit comments

Comments
 (0)