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

Psycopg Tracing

Trace Psycopg PostgreSQL spans with Judgment.

Psycopg tracing uses the standard OpenTelemetry Psycopg instrumentation and routes PostgreSQL spans through Judgment.

uv add judgeval psycopg opentelemetry-instrumentation-psycopg
pip install judgeval psycopg opentelemetry-instrumentation-psycopg
from judgeval import Tracer
from opentelemetry.instrumentation.psycopg import PsycopgInstrumentor

Tracer.init(project_name="psycopg_app")
Tracer.registerOTELInstrumentation(PsycopgInstrumentor())

# Create connections normally after registration.
# with psycopg.connect("postgresql://user:password@localhost/db") as conn:
#     conn.execute("select 1")

Was this page helpful?