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

PyMongo Tracing

Trace PyMongo spans with Judgment.

PyMongo tracing uses the standard OpenTelemetry PyMongo instrumentation and routes MongoDB spans through Judgment.

uv add judgeval pymongo opentelemetry-instrumentation-pymongo
pip install judgeval pymongo opentelemetry-instrumentation-pymongo
from judgeval import Tracer
from opentelemetry.instrumentation.pymongo import PymongoInstrumentor
from pymongo import MongoClient

Tracer.init(project_name="pymongo_app")
Tracer.registerOTELInstrumentation(PymongoInstrumentor())

# Create clients normally after registration.
# client = MongoClient("mongodb://localhost:27017")
# client.my_db.my_collection.find_one({})

Was this page helpful?