This release is a pre-release and may not be stable for production use.
OpenTelemetry asyncio Instrumentation
AsyncioInstrumentor: Tracing Requests Made by the Asyncio Library
The opentelemetry-instrumentation-asyncio package allows tracing asyncio applications. It also includes metrics for duration and counts of coroutines and futures. Metrics are generated even if coroutines are not traced.
Set the names of coroutines you want to trace.
export OTEL_PYTHON_ASYNCIO_COROUTINE_NAMES_TO_TRACE=coro_name,coro_name2,coro_name3
If you want to trace specific blocking functions executed with the to_thread function of asyncio, set the name of the functions in OTEL_PYTHON_ASYNCIO_TO_THREAD_FUNCTION_NAMES_TO_TRACE.
export OTEL_PYTHON_ASYNCIO_TO_THREAD_FUNCTION_NAMES_TO_TRACE=func_name,func_name2,func_name3
You can enable tracing futures with OTEL_PYTHON_ASYNCIO_FUTURE_TRACE_ENABLED
export OTEL_PYTHON_ASYNCIO_FUTURE_TRACE_ENABLED=true
Run instrumented application
1. coroutine
# export OTEL_PYTHON_ASYNCIO_COROUTINE_NAMES_TO_TRACE=sleep
import asyncio
from opentelemetry.instrumentation.asyncio import AsyncioInstrumentor
AsyncioInstrumentor().instrument()
async def main():
await asyncio.create_task(asyncio.sleep(0.1))
asyncio.run(main())
2. future
# export OTEL_PYTHON_ASYNCIO_FUTURE_TRACE_ENABLED=true
import asyncio
from opentelemetry.instrumentation.asyncio import AsyncioInstrumentor
AsyncioInstrumentor().instrument()
async def main():
future = asyncio.Future()
future.set_result(1)
await asyncio.ensure_future(future)
asyncio.run(main())
3. to_thread
# export OTEL_PYTHON_ASYNCIO_TO_THREAD_FUNCTION_NAMES_TO_TRACE=func
import asyncio
from opentelemetry.instrumentation.asyncio import AsyncioInstrumentor
AsyncioInstrumentor().instrument()
async def main():
await asyncio.to_thread(func)
def func():
pass
asyncio.run(main())
asyncio metric types
asyncio.process.duration (seconds) - Duration of asyncio process
asyncio.process.created ({process}) - Number of asyncio process
API
Installation
pip install opentelemetry-instrumentation-asyncio
References
Metadata
Release files for opentelemetry-instrumentation-asyncio 0.66b1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| opentelemetry_instrumentation_asyncio-0.66b1.tar.gz | 14.7 kB | Without provenance | Details for opentelemetry_instrumentation_asyncio-0.66b1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| opentelemetry_instrumentation_asyncio-0.66b1-py3-none-any.whl | Python 3 | none | any | Details for opentelemetry_instrumentation_asyncio-0.66b1-py3-none-any.whl |
Total release size: 27.9 kB
Release files / opentelemetry_instrumentation_asyncio-0.66b1.tar.gz
| Download URL | opentelemetry_instrumentation_asyncio-0.66b1.tar.gz |
|---|---|
| Size | 14.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c2a593daee5eadd487fd08608b506da25f8e3805cbce1d5595097f8b427991d0
|
|
BLAKE2b-256 checksum How to use checksums |
49770427ca3932c41f512aa55684c9794f759125c9ddf9deafed2e634c04c9c2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.10.22
|
Release files / opentelemetry_instrumentation_asyncio-0.66b1-py3-none-any.whl
| Download URL | opentelemetry_instrumentation_asyncio-0.66b1-py3-none-any.whl |
|---|---|
| Size | 13.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
026585c60432672bf9efd03ef428f1eeec6c1607ee307aa5916eaca6567a8887
|
|
BLAKE2b-256 checksum How to use checksums |
8603692677ee91bc9d775a3a575c7c449aa60aa8cb5a600432bd087d32278321
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.10.22
|
Security for opentelemetry-instrumentation-asyncio 0.66b1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.