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

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.66b2
File Size Uploaded Provenance Actions
opentelemetry_instrumentation_asyncio-0.66b2.tar.gz 14.6 kB Without provenance Details for opentelemetry_instrumentation_asyncio-0.66b2.tar.gz

Built distribution (wheel)

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

Total release size: 27.9 kB

Release files / opentelemetry_instrumentation_asyncio-0.66b2.tar.gz

Download URL opentelemetry_instrumentation_asyncio-0.66b2.tar.gz
Size 14.6 kB
Tags Source
SHA-256 checksum
How to use checksums
41e21485a043d107da86b69032cc87393d5377cd306d6cddee64c6fddd17487c
BLAKE2b-256 checksum
How to use checksums
9cbc3e450171c2be5fc270bd7abb5c3c67c57158effc321b3f3d5682fda442f5
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.66b2-py3-none-any.whl

Download URL opentelemetry_instrumentation_asyncio-0.66b2-py3-none-any.whl
Size 13.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8bd83268754604b42ac807acfde11a5d00348fed7b550df3140ffa4496a74147
BLAKE2b-256 checksum
How to use checksums
137c040b650db668f7df2d21ca731c1542c232e69173eed4faa1cd2f89a3bb7b
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.66b2

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