diff --git a/src/Tingle.Extensions.MongoDB/Extensions/IServiceCollectionExtensions.cs b/src/Tingle.Extensions.MongoDB/Extensions/IServiceCollectionExtensions.cs index 973c3bd..4afdaa7 100644 --- a/src/Tingle.Extensions.MongoDB/Extensions/IServiceCollectionExtensions.cs +++ b/src/Tingle.Extensions.MongoDB/Extensions/IServiceCollectionExtensions.cs @@ -2,6 +2,7 @@ using Microsoft.Extensions.DependencyInjection.Extensions; using Microsoft.Extensions.Hosting; using MongoDB.Driver; +using MongoDB.Driver.Core.Extensions.DiagnosticSources; using System.Diagnostics.CodeAnalysis; using System.Reflection; using Tingle.Extensions.MongoDB; @@ -32,13 +33,14 @@ public static IServiceCollection AddMongoDatabaseSetup(this IServiceCo this IServiceCollection services, IConfiguration configuration, Action? optionsAction = null, + InstrumentationOptions? instrumentationOptions = null, ServiceLifetime contextLifetime = ServiceLifetime.Singleton, ServiceLifetime optionsLifetime = ServiceLifetime.Singleton) where TContext : MongoDbContext { var connectionString = configuration.GetConnectionString("Mongo"); return connectionString is not null - ? AddMongoDbContext(services, connectionString: connectionString, optionsAction, contextLifetime, optionsLifetime) + ? AddMongoDbContext(services, connectionString: connectionString, optionsAction, instrumentationOptions, contextLifetime, optionsLifetime) : AddMongoDbContext(services, optionsAction, contextLifetime, optionsLifetime); } @@ -46,13 +48,14 @@ public static IServiceCollection AddMongoDatabaseSetup(this IServiceCo this IServiceCollection services, string connectionString, Action? optionsAction = null, + InstrumentationOptions? instrumentationOptions = null, ServiceLifetime contextLifetime = ServiceLifetime.Singleton, ServiceLifetime optionsLifetime = ServiceLifetime.Singleton) where TContext : MongoDbContext { return AddMongoDbContext(services, options => { - options.UseMongoConnectionString(connectionString); + options.UseMongoConnectionString(connectionString, instrumentationOptions); optionsAction?.Invoke(options); }, contextLifetime, optionsLifetime); }