Skip to content
Furkan Güngör edited this page Mar 27, 2022 · 3 revisions

Usage

Install EasyProfiler.Mongo from Nuget Package

Initilaze EasyProfilerDbContext in Program.cs to save the results.

Sample

builder.Services.AddEasyProfilerDbContext(options =>
{
  options.ConnectionString = "mongodb://localhost:27017";
  options.Database = "{yourDatabaseName}";
}, options=>
{
  options.Resulation = EasyProfiler.CronJob.Common.Resulation.HIGH;
});

and EasyProfilerInterceptor extensions add for own MongoContext.

Sample

public MongoContext(IServiceProvider serviceProvider)
{
    var client = new MongoClient(new MongoClientSettings
    {
        Server = new MongoServerAddress("{yourHost}"),
        ClusterConfigurator = cb =>
        {
            cb.Subscribe<CommandStartedEvent>(e =>
            {
                e.InitilazeStartedEvent(serviceProvider);
            });
            cb.Subscribe<CommandSucceededEvent>(e =>
            {
                e.InitilazeSucceededEvent(serviceProvider);
            });
        }
    });
}

Welcome to the EasyProfiler wiki!

Topics:

Clone this wiki locally