Documentation ¶
Overview ¶
Package mongo provides functions to trace the mongodb/mongo-go-driver package (https://github.com/mongodb/mongo-go-driver). The minimum required version is v0.0.17 (Alpha 17). Since this driver is still in Alpha and subject to change from one release to another, stability of this package can not be guaranteed.
`NewMonitor` will return an event.CommandMonitor which is used to trace requests.
Example ¶
package main import ( "context" "github.com/mongodb/mongo-go-driver/bson" "github.com/mongodb/mongo-go-driver/mongo" "github.com/mongodb/mongo-go-driver/options" mongotrace "gopkg.in/DataDog/dd-trace-go.v1/contrib/mongodb/mongo-go-driver/mongo" ) func main() { // connect to MongoDB client, err := mongo.Connect(context.Background(), "mongodb://localhost:27017", options.Client().SetMonitor(mongotrace.NewMonitor())) if err != nil { panic(err) } db := client.Database("example") inventory := db.Collection("inventory") inventory.InsertOne(context.Background(), bson.NewDocument( bson.EC.String("item", "canvas"), bson.EC.Int32("qty", 100), bson.EC.ArrayFromElements("tags", bson.VC.String("cotton"), ), bson.EC.SubDocumentFromElements("size", bson.EC.Int32("h", 28), bson.EC.Double("w", 35.5), bson.EC.String("uom", "cm"), ), )) }
Output:
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewMonitor ¶
func NewMonitor() *event.CommandMonitor
NewMonitor creates a new mongodb event CommandMonitor.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.