Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

OpenTelemetry asyncio Instrumentation

pypi

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.66b0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for opentelemetry-instrumentation-asyncio 0.66b0
File Size Uploaded Provenance Actions
opentelemetry_instrumentation_asyncio-0.66b0.tar.gz 14.7 kB Without provenance Details for opentelemetry_instrumentation_asyncio-0.66b0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for opentelemetry-instrumentation-asyncio 0.66b0
File Interpreter ABI Platform Actions
opentelemetry_instrumentation_asyncio-0.66b0-py3-none-any.whl Python 3 none any Details for opentelemetry_instrumentation_asyncio-0.66b0-py3-none-any.whl

Total release size: 27.9 kB

Release files / opentelemetry_instrumentation_asyncio-0.66b0.tar.gz

Download URL opentelemetry_instrumentation_asyncio-0.66b0.tar.gz
Size 14.7 kB
Tags Source
SHA-256 checksum
How to use checksums
72bbe1ec3d01838e7a89bde91eeaeb88534d4340a129509c51b71edaf25fafe7
BLAKE2b-256 checksum
How to use checksums
e54f130be9ca0475ea362b43c8e396443bb80d59de925f7c5f79a4e924880f56
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.10.21

Release files / opentelemetry_instrumentation_asyncio-0.66b0-py3-none-any.whl

Download URL opentelemetry_instrumentation_asyncio-0.66b0-py3-none-any.whl
Size 13.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ddaf4e6b4e9be21c9b428f27b04ca67758fc637cba2069821313796f1ccf722b
BLAKE2b-256 checksum
How to use checksums
02f3183ef1efc77f20bf298ab5b21c05b654aa45896f063f57c455b12591c894
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.10.21

Security for opentelemetry-instrumentation-asyncio 0.66b0

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.

Release history Release notifications | RSS feed

This release
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page