Documentation ¶
Overview ¶
Package mongo provides functions to trace the mongodb/mongo-go-driver package (https://go.mongodb.org/mongo-driver).
`NewMonitor` will return an event.CommandMonitor which is used to trace requests.
Example ¶
package main import ( "context" "go.mongodb.org/mongo-driver/bson" "go.mongodb.org/mongo-driver/mongo" "go.mongodb.org/mongo-driver/mongo/options" mongotrace "github.com/signalfx/signalfx-go-tracing/contrib/mongodb/mongo-go-driver/mongo" ) func main() { // connect to MongoDB opts := options.Client() opts.SetMonitor(mongotrace.NewMonitor()) client, err := mongo.Connect(context.Background(), opts.ApplyURI("mongodb://localhost:27017")) if err != nil { panic(err) } db := client.Database("example") inventory := db.Collection("inventory") inventory.InsertOne(context.Background(), bson.D{ {Key: "item", Value: "canvas"}, {Key: "qty", Value: 100}, {Key: "tags", Value: bson.A{"cotton"}}, {Key: "size", Value: bson.D{ {Key: "h", Value: 28}, {Key: "w", Value: 35.5}, {Key: "uom", Value: "cm"}, }}, }) }
Output:
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewMonitor ¶
func NewMonitor(opts ...Option) *event.CommandMonitor
NewMonitor creates a new mongodb event CommandMonitor.
Types ¶
type Option ¶
type Option func(*config)
Option represents an option that can be passed to Dial.
func WithAnalytics ¶
WithAnalytics enables Trace Analytics for all started spans.
func WithAnalyticsRate ¶
WithAnalyticsRate sets the sampling rate for Trace Analytics events correlated to started spans.
func WithServiceName ¶
WithServiceName sets the given service name for the dialled connection. When the service name is not explicitly set it will be inferred based on the request to AWS.
Click to show internal directories.
Click to hide internal directories.