Know what queries are been executed and what needs investigation and improvements in our MongoDB application.
Miniprofiler is an OpenSource started by StackExchange, that makes it extremely easy to understand and profile your .NET and ASP.NET applications. And offer inbox profiling for EF and ADO.NET, but not for MongoDB.
This project adds a new custom Profier category to Miniprofiler for MongoDB
Goals:
- Easy identity bottlenecks.
- Profile the response timing of your MongoDB.
- Understood better the Mongo query generated by the Driver or LINQ.
- See the generated query quicker and easier.
- C#, .NET 7
- and Love.
Install, and set up your MongoClient with MiniProfilerMongoDbEventSubscriber
and follow Miniprofiiler documentation to know how to use Miniprofiiler. Or follow our samples.
- Your project needs to be compatible with .NET Standard 2.1
- Miniprofiller
- MongoDB Driver
- MiniProfiler.MongoDB - this project
Register MiniProfilerMongoDbEventSubscriber
in your MongoClient
instance.
const string connectionString = "mongodb://localhost:27017/?readPreference=primary&ssl=false&directConnection=true";
var mongoClientSettings = MongoClientSettings.FromUrl(new MongoUrl(connectionString));
mongoClientSettings.ClusterConfigurator = cb =>
{
cb.Subscribe(new MiniProfilerMongoDbEventSubscriber()); // Hook MongoDriver Events to add MiniProfiler custom profiling data.
};
var dbClient = new MongoClient(mongoClientSettings);
- Install the
MiniProfiler.MongoDB
package (COMMING SOON)
Follow Miniprofiiler documentation to know how to use Miniprofiiler. Or follow our samples.
For examples, please refer to the samples folder
Distributed under the MIT License. See LICENSE for more information.
- Rafael Silveira Cordeiro - FullStack Software Engineer with 25+ years of experience in software development. - Code, Samples, Documentation