Judgment Labs Logo
Other

ASGI

Trace generic ASGI applications with Judgment.

ASGI tracing uses the standard OpenTelemetry ASGI middleware and routes request spans through Judgment.

uv add judgeval opentelemetry-instrumentation-asgi
pip install judgeval opentelemetry-instrumentation-asgi
asgi_tracing.py
from judgeval import Tracer
from opentelemetry.instrumentation.asgi import OpenTelemetryMiddleware

Tracer.init(project_name="asgi_app")


async def application(scope, receive, send):
    await send(
        {
            "type": "http.response.start",
            "status": 200,
            "headers": [(b"content-type", b"text/plain")],
        }
    )
    await send({"type": "http.response.body", "body": b"hello"})


app = OpenTelemetryMiddleware(application)

On this page

No Headings