OpenTelemetry pymongo Instrumentation

The integration with MongoDB supports the pymongo library, it can be enabled using the PymongoInstrumentor.

Usage

from pymongo import MongoClient
from opentelemetry.instrumentation.pymongo import PymongoInstrumentor


PymongoInstrumentor().instrument()
client = MongoClient()
db = client["MongoDB_Database"]
collection = db["MongoDB_Collection"]
collection.find_one()

API

class opentelemetry.instrumentation.pymongo.CommandTracer(tracer)[source]

Bases: pymongo.monitoring.CommandListener

started(event)[source]

Method to handle a pymongo CommandStartedEvent

succeeded(event)[source]

Method to handle a pymongo CommandSucceededEvent

failed(event)[source]

Method to handle a pymongo CommandFailedEvent

class opentelemetry.instrumentation.pymongo.PymongoInstrumentor(*args, **kwargs)[source]

Bases: opentelemetry.instrumentation.instrumentor.BaseInstrumentor