Einrichtung
Um Ihre Nutzung von MongoDB zu instrumentieren, müssen Sie das offizielle OpenTelemetry-Instrumentierungspaket importieren:otelmongo.NewMonitor() als Monitor in den Verbindungsoptionen hinzu, wie im folgenden Beispiel gezeigt.
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() als Monitor in den Verbindungsoptionen hinzu, wie im folgenden Beispiel gezeigt.
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)
}
War diese Seite hilfreich?