File tree 1 file changed +38
-0
lines changed
instrumentation/opentelemetry-instrumentation-aiohttp-client
1 file changed +38
-0
lines changed Original file line number Diff line number Diff line change @@ -17,6 +17,44 @@ Installation
17
17
pip install opentelemetry-instrumentation-aiohttp-client
18
18
19
19
20
+ Example
21
+ -------
22
+
23
+ .. code :: python
24
+
25
+ import asyncio
26
+
27
+ import aiohttp
28
+
29
+ from opentelemetry.instrumentation.aiohttp_client import AioHttpClientInstrumentor
30
+ from opentelemetry import trace
31
+ from opentelemetry.exporter import jaeger
32
+ from opentelemetry.sdk.trace import TracerProvider
33
+ from opentelemetry.sdk.trace.export import BatchExportSpanProcessor
34
+
35
+
36
+ _JAEGER_EXPORTER = jaeger.JaegerSpanExporter(
37
+ service_name = " example-xxx" ,
38
+ agent_host_name = " localhost" ,
39
+ agent_port = 6831 ,
40
+ )
41
+
42
+ _TRACE_PROVIDER = TracerProvider()
43
+ _TRACE_PROVIDER .add_span_processor(BatchExportSpanProcessor(_JAEGER_EXPORTER ))
44
+ trace.set_tracer_provider(_TRACE_PROVIDER )
45
+
46
+ AioHttpClientInstrumentor().instrument()
47
+
48
+
49
+ async def span_emitter ():
50
+ async with aiohttp.ClientSession() as session:
51
+ async with session.get(" https://example.com" ) as resp:
52
+ print (resp.status)
53
+
54
+
55
+ asyncio.run(span_emitter())
56
+
57
+
20
58
References
21
59
----------
22
60
You can’t perform that action at this time.
0 commit comments