You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: instrumentation/opentelemetry-instrumentation-aiohttp-client/src/opentelemetry/instrumentation/aiohttp_client/__init__.py
+15-7
Original file line number
Diff line number
Diff line change
@@ -22,24 +22,29 @@
22
22
23
23
.. code:: python
24
24
25
+
import asyncio
25
26
import aiohttp
26
27
from opentelemetry.instrumentation.aiohttp_client import create_trace_config
27
28
import yarl
28
29
29
30
def strip_query_params(url: yarl.URL) -> str:
30
31
return str(url.with_query(None))
31
32
32
-
async with aiohttp.ClientSession(trace_configs=[create_trace_config(
33
+
async def get(url):
34
+
async with aiohttp.ClientSession(trace_configs=[create_trace_config(
33
35
# Remove all query params from the URL attribute on the span.
34
36
url_filter=strip_query_params,
35
-
)]) as session:
36
-
async with session.get(url) as response:
37
-
await response.text()
37
+
)]) as session:
38
+
async with session.get(url) as response:
39
+
await response.text()
40
+
41
+
asyncio.run(get("https://example.com"))
38
42
39
43
Instrumenting all client sessions:
40
44
41
45
.. code:: python
42
46
47
+
import asyncio
43
48
import aiohttp
44
49
from opentelemetry.instrumentation.aiohttp_client import (
0 commit comments