Metadata-Version: 2.4
Name: traceAI-mongodb
Version: 0.1.1
Summary: OpenTelemetry instrumentation for MongoDB Atlas Vector Search
License: Apache-2.0
Keywords: opentelemetry,mongodb,atlas,vector-search,tracing,observability,rag,traceai,futureagi,llm,mongodb-vector
Author: Future AGI
Author-email: no-reply@futureagi.com
Requires-Python: >3.9,<3.14
Classifier: Framework :: OpenTelemetry
Classifier: Framework :: OpenTelemetry :: Instrumentations
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.9
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Topic :: System :: Monitoring
Requires-Dist: fi-instrumentation-otel (>=0.1.11)
Requires-Dist: pymongo (>=4.6.0)
Requires-Dist: wrapt (>=1.0.0)
Project-URL: Changelog, https://github.com/future-agi/traceAI/blob/dev/python/frameworks/mongodb-vector/CHANGELOG.md
Project-URL: Documentation, https://docs.futureagi.com/docs/tracing
Project-URL: Homepage, https://futureagi.com
Project-URL: Issues, https://github.com/future-agi/traceAI/issues
Project-URL: Repository, https://github.com/future-agi/traceAI/tree/dev/python/frameworks/mongodb-vector
Description-Content-Type: text/markdown

# traceAI-mongodb

OpenTelemetry instrumentation for [MongoDB Atlas Vector Search](https://www.mongodb.com/docs/atlas/atlas-vector-search/).

## Installation

```bash
pip install traceAI-mongodb
```

## Quick Start

```python
from fi_instrumentation import register
from traceai_mongodb import MongoDBInstrumentor
from pymongo import MongoClient

trace_provider = register(project_name="my-rag-app")
MongoDBInstrumentor().instrument(tracer_provider=trace_provider)

client = MongoClient("mongodb+srv://...")
db = client["mydb"]
collection = db["documents"]

# Vector search operations are traced
results = collection.aggregate([
    {
        "$vectorSearch": {
            "index": "vector_index",
            "path": "embedding",
            "queryVector": [0.1, 0.2, ...],
            "numCandidates": 100,
            "limit": 5
        }
    }
])
```

## Instrumented Operations

| Operation | Span Name | Description |
|-----------|-----------|-------------|
| `aggregate` | `mongodb aggregate` | Aggregation pipeline (includes $vectorSearch) |
| `insert_one` | `mongodb insert_one` | Insert single document |
| `insert_many` | `mongodb insert_many` | Batch insert |
| `update_one` | `mongodb update_one` | Update single document |
| `update_many` | `mongodb update_many` | Batch update |
| `delete_one` | `mongodb delete_one` | Delete single document |
| `delete_many` | `mongodb delete_many` | Batch delete |
| `find` | `mongodb find` | Query documents |
| `find_one` | `mongodb find_one` | Find single document |

## Vector Search Detection

The instrumentor automatically detects `$vectorSearch` stages in aggregation pipelines and captures:
- Vector index name
- Query vector dimensions
- numCandidates
- limit

## License

Apache License 2.0

