Skip to content
Judgment Labs
Esc
↑↓navigate↵open⌘Jpreview

ASGI Tracing

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
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)

Was this page helpful?