MongoDB.Driveredit

Quick startedit

A prerequisite for auto instrumentation with [MongoDb.Driver] is to configure the MongoClient with MongoDbEventSubscriber:

var settings = MongoClientSettings.FromConnectionString(mongoConnectionString);

settings.ClusterConfigurator = builder => builder.Subscribe(new MongoDbEventSubscriber());
var mongoClient = new MongoClient(settings);

Once the above configuration is in place, and if the agent is included by referencing the Elastic.Apm.NetCoreAll package, it will automatically capture calls to MongoDB on every active transaction. Otherwise, you can manually activate auto instrumentation from the Elastic.Apm.MongoDb package by calling

Agent.Subscribe(new MongoDbDiagnosticsSubscriber());