---
title: "PyMongo Tracing"
description: "Trace PyMongo spans with Judgment."
sidebar:
  label: "PyMongo"
seo:
  title: "PyMongo Tracing with Judgment | Integration Docs"
  description: "Trace PyMongo spans with Judgment to connect application behavior to production AI agent monitoring and evaluation."
---

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

{/* @test-flow
  id: tracing-db-pymongo
  lang: python
  env: JUDGMENT_API_KEY, JUDGMENT_ORG_ID
*/}

**uv**

```bash
uv add judgeval pymongo opentelemetry-instrumentation-pymongo
```

**pip**

```bash
pip install judgeval pymongo opentelemetry-instrumentation-pymongo
```

```python title="pymongo_tracing.py"
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({})
```
