logfire icon indicating copy to clipboard operation
logfire copied to clipboard

Adding support for opentelemetry-instrumentation-asyncio

Open tyong920 opened this issue 9 months ago • 2 comments

Description

Currently, the project lacks support [Correct me if i'm wrong] for opentelemetry-instrumentation-asyncio, which would allow better tracing and monitoring of asyncio-based operations. Integrating this instrumentation would enhance observability, making it easier to diagnose performance bottlenecks and errors in async workflows.

Official package: opentelemetry-instrumentation-asyncio

tyong920 avatar Mar 20 '25 03:03 tyong920

Pretty much any opentelemetry-instrumentation-* will just work as described with logfire activated. Using the first example from their docs:

import asyncio
import os

import logfire
from opentelemetry.instrumentation.asyncio import AsyncioInstrumentor

logfire.configure()
os.environ['OTEL_PYTHON_ASYNCIO_COROUTINE_NAMES_TO_TRACE'] = 'sleep'

AsyncioInstrumentor().instrument()


async def main():
    await asyncio.create_task(asyncio.sleep(0.1))


asyncio.run(main())

Image

Also check out https://logfire.pydantic.dev/docs/reference/api/logfire/#logfire.Logfire.log_slow_async_callbacks . I see we need to make this more discoverable in docs.

alexmojaki avatar Mar 20 '25 10:03 alexmojaki

Appreciate the info—I’ll check it out!

tyong920 avatar Mar 27 '25 05:03 tyong920