Improve asyncio instrumentation examples (#3312)

* Improve asyncio instrumentation examples

* Port asyncio instrumentation example changes to README.rst

---------

Co-authored-by: Riccardo Magliocchetti <riccardo.magliocchetti@gmail.com>
This commit is contained in:
Andre Murbach Maidl 2025-03-07 13:27:35 -03:00 committed by GitHub
parent ad2fe813ab
commit d5dce5de99
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 12 additions and 0 deletions

View File

@ -55,6 +55,11 @@ Run instrumented application
# export OTEL_PYTHON_ASYNCIO_FUTURE_TRACE_ENABLED=true
import asyncio
from opentelemetry.instrumentation.asyncio import AsyncioInstrumentor
AsyncioInstrumentor().instrument()
loop = asyncio.get_event_loop()
future = asyncio.Future()

View File

@ -41,6 +41,11 @@ Run instrumented application
# export OTEL_PYTHON_ASYNCIO_FUTURE_TRACE_ENABLED=true
import asyncio
from opentelemetry.instrumentation.asyncio import AsyncioInstrumentor
AsyncioInstrumentor().instrument()
loop = asyncio.get_event_loop()
future = asyncio.Future()
@ -52,6 +57,8 @@ Run instrumented application
-------------
.. code:: python
# export OTEL_PYTHON_ASYNCIO_TO_THREAD_FUNCTION_NAMES_TO_TRACE=func
import asyncio
from opentelemetry.instrumentation.asyncio import AsyncioInstrumentor