Instrumentation for MongoDB works with the official MongoDb.Driver 2.4.4+ driver packages. A prerequisite for auto instrumentation is to configure the MongoClient with MongoDbEventSubscriber
in your database initialization file.
using Atatus.NetCoreAll;
using Atatus.MongoDb;
var settings = MongoClientSettings.FromConnectionString(mongoConnectionString);
settings.ClusterConfigurator = builder => builder.Subscribe(new MongoDbEventSubscriber());
var mongoClient = new MongoClient(settings);
Once the above configuration is in place, if the agent is included by referencing the Atatus.NetCoreAll package, it will automatically capture calls to MongoDB on every active transaction, and no further action is required.
In certain cases, you may need to manually activate auto instrumentation of MongoDB. You can do that by passing MongoDbDiagnosticsSubscriber
to the Subscribe method.
Agent.Subscribe(new MongoDbDiagnosticsSubscriber());
MongoDB integration is currently supported on .NET Core and newer. Due to MongoDb.Driver assemblies not being strongly named, they cannot be used with Atatus strongly named assemblies on .NET Framework.