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

Starlette Tracing

Trace Starlette request spans with Judgment.

Starlette tracing uses the standard OpenTelemetry Starlette instrumentation and routes request spans through Judgment.

uv add judgeval starlette opentelemetry-instrumentation-starlette
pip install judgeval starlette opentelemetry-instrumentation-starlette
from judgeval import Tracer
from opentelemetry.instrumentation.starlette import StarletteInstrumentor
from starlette.applications import Starlette
from starlette.responses import JSONResponse
from starlette.routing import Route


async def hello(request):
    return JSONResponse({"message": "hello"})


Tracer.init(project_name="starlette_app")

app = Starlette(routes=[Route("/hello", hello)])
StarletteInstrumentor.instrument_app(app)

Was this page helpful?