rafaelsc / MiniProfiler.MongoDB

MongoDB query profiling capabilities for MiniProfiler

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool


Logo

Mini Query Profiler for MongoDB

Know what queries are been executed and what needs investigation and improvements in our MongoDB application.

Table Of Contents

About The Project

Screen Shot

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.

Built With

  • C#, .NET 7
  • and Love.

Getting Started

Install, and set up your MongoClient with MiniProfilerMongoDbEventSubscriber and follow Miniprofiiler documentation to know how to use Miniprofiiler. Or follow our samples.

Prerequisites

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);

Installation

  1. Install the MiniProfiler.MongoDB package (COMMING SOON)

Usage

Follow Miniprofiiler documentation to know how to use Miniprofiiler. Or follow our samples.

For examples, please refer to the samples folder

License

Distributed under the MIT License. See LICENSE for more information.

Authors

  • Rafael Silveira Cordeiro - FullStack Software Engineer with 25+ years of experience in software development. - Code, Samples, Documentation

Acknowledgements

About

MongoDB query profiling capabilities for MiniProfiler

License:MIT License


Languages

Language:C# 100.0%