From cc4a7862bd6062cc722779144d5d1e7840b1af9f Mon Sep 17 00:00:00 2001 From: Andre Murbach Maidl Date: Fri, 28 Feb 2025 14:00:53 -0300 Subject: [PATCH 1/2] Improve asyncio instrumentation examples --- .../src/opentelemetry/instrumentation/asyncio/__init__.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/instrumentation/opentelemetry-instrumentation-asyncio/src/opentelemetry/instrumentation/asyncio/__init__.py b/instrumentation/opentelemetry-instrumentation-asyncio/src/opentelemetry/instrumentation/asyncio/__init__.py index 2d1b063dfd..9905d91dbd 100644 --- a/instrumentation/opentelemetry-instrumentation-asyncio/src/opentelemetry/instrumentation/asyncio/__init__.py +++ b/instrumentation/opentelemetry-instrumentation-asyncio/src/opentelemetry/instrumentation/asyncio/__init__.py @@ -41,6 +41,11 @@ async def main(): # 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 @@ async def main(): ------------- .. code:: python + # export OTEL_PYTHON_ASYNCIO_TO_THREAD_FUNCTION_NAMES_TO_TRACE=func + import asyncio from opentelemetry.instrumentation.asyncio import AsyncioInstrumentor From 0235428689d1cbcdbdb24596408a58f57e008b71 Mon Sep 17 00:00:00 2001 From: Andre Murbach Maidl Date: Fri, 28 Feb 2025 14:36:09 -0300 Subject: [PATCH 2/2] Port asyncio instrumentation example changes to README.rst --- .../opentelemetry-instrumentation-asyncio/README.rst | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/instrumentation/opentelemetry-instrumentation-asyncio/README.rst b/instrumentation/opentelemetry-instrumentation-asyncio/README.rst index d78e846793..9c1c3450c4 100644 --- a/instrumentation/opentelemetry-instrumentation-asyncio/README.rst +++ b/instrumentation/opentelemetry-instrumentation-asyncio/README.rst @@ -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()