OpenTelemetry pymongo Integration

The integration with MongoDB supports the pymongo library and is specified to trace_integration using 'pymongo'.

Usage

from pymongo import MongoClient
from opentelemetry.trace import tracer_provider
from opentelemetry.trace.ext.pymongo import trace_integration

trace_integration(tracer_provider())
client = MongoClient()
db = client["MongoDB_Database"]
collection = db["MongoDB_Collection"]
collection.find_one()

API

opentelemetry.ext.pymongo.trace_integration(tracer=None)[source]

Integrate with pymongo to trace it using event listener. https://api.mongodb.com/python/current/api/pymongo/monitoring.html

class opentelemetry.ext.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