Setup
To instrument your MongoDB usage, you’ll need to import the OpenTelemetry official instrumentation package:otelmongo.NewMonitor() as a monitor in the connection options as shown in the example below.
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
import "go.opentelemetry.io/contrib/instrumentation/go.mongodb.org/mongo-driver/mongo/otelmongo"
otelmongo.NewMonitor() as a monitor in the connection options as shown in the example below.
opts := options.Client()
opts.Monitor = otelmongo.NewMonitor()
opts.ApplyURI("mongodb://your.mongo.host:27017")
client, err := mongo.Connect(ctx, opts)
if err != nil {
panic(err)
}
Was this page helpful?