diff --git a/src/Tingle.Extensions.MongoDB/Extensions/IServiceCollectionExtensions.cs b/src/Tingle.Extensions.MongoDB/Extensions/IServiceCollectionExtensions.cs index 4afdaa7..246eaf0 100644 --- a/src/Tingle.Extensions.MongoDB/Extensions/IServiceCollectionExtensions.cs +++ b/src/Tingle.Extensions.MongoDB/Extensions/IServiceCollectionExtensions.cs @@ -2,7 +2,6 @@ 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; @@ -33,14 +32,13 @@ 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, instrumentationOptions, contextLifetime, optionsLifetime) + ? AddMongoDbContext(services, connectionString, optionsAction, contextLifetime, optionsLifetime) : AddMongoDbContext(services, optionsAction, contextLifetime, optionsLifetime); } @@ -48,14 +46,13 @@ 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, instrumentationOptions); + options.UseMongoConnectionString(connectionString); optionsAction?.Invoke(options); }, contextLifetime, optionsLifetime); } diff --git a/src/Tingle.Extensions.MongoDB/MongoDbContextOptions.cs b/src/Tingle.Extensions.MongoDB/MongoDbContextOptions.cs index 194c47f..ee73f76 100644 --- a/src/Tingle.Extensions.MongoDB/MongoDbContextOptions.cs +++ b/src/Tingle.Extensions.MongoDB/MongoDbContextOptions.cs @@ -1,5 +1,4 @@ using MongoDB.Driver; -using MongoDB.Driver.Core.Extensions.DiagnosticSources; using System.Diagnostics.CodeAnalysis; namespace Microsoft.Extensions.DependencyInjection; @@ -121,9 +120,8 @@ public virtual MongoDbContextOptionsBuilder UseApplicationServiceProvider(IServi /// Sets the to use when configuring the context. /// /// The to be used - /// The options to use for instrumentation. /// - public virtual MongoDbContextOptionsBuilder UseMongoUrl(MongoUrl url, InstrumentationOptions? instrumentationOptions = null) + public virtual MongoDbContextOptionsBuilder UseMongoUrl(MongoUrl url) { ArgumentNullException.ThrowIfNull(url); if (string.IsNullOrWhiteSpace(url.DatabaseName)) @@ -133,15 +131,6 @@ public virtual MongoDbContextOptionsBuilder UseMongoUrl(MongoUrl url, Instrument options.AddMetadata(url); - // add the default event subscriber - ConfigureMongoClientSettings(settings => - { - settings.ClusterConfigurator = builder => - { - builder.Subscribe(new DiagnosticsActivityEventSubscriber(instrumentationOptions ?? new() { CaptureCommandText = true })); - }; - }); - return this; } @@ -154,12 +143,11 @@ public virtual MongoDbContextOptionsBuilder UseMongoUrl(MongoUrl url, Instrument /// mongodb://[username:password@]host1[:port1][,host2[:port2],...[,hostN[:portN]]][/[database][?options]] /// e.g. mongodb://localhost:27017/myDatabase /// - /// The options to use for instrumentation. /// - public virtual MongoDbContextOptionsBuilder UseMongoConnectionString(string connectionString, InstrumentationOptions? instrumentationOptions = null) + public virtual MongoDbContextOptionsBuilder UseMongoConnectionString(string connectionString) { ArgumentNullException.ThrowIfNull(connectionString); - return UseMongoUrl(new MongoUrl(connectionString), instrumentationOptions); + return UseMongoUrl(new MongoUrl(connectionString)); } /// @@ -228,10 +216,9 @@ public MongoDbContextOptionsBuilder() : this(new MongoDbContextOptions /// Sets the to use when configuring the context. /// /// The to be used - /// The options to use for instrumentation. /// - public new virtual MongoDbContextOptionsBuilder UseMongoUrl(MongoUrl url, InstrumentationOptions? instrumentationOptions = null) - => (MongoDbContextOptionsBuilder)base.UseMongoUrl(url, instrumentationOptions); + public new virtual MongoDbContextOptionsBuilder UseMongoUrl(MongoUrl url) + => (MongoDbContextOptionsBuilder)base.UseMongoUrl(url); /// /// Sets the to use when configuring the context by @@ -242,10 +229,9 @@ public MongoDbContextOptionsBuilder() : this(new MongoDbContextOptions /// mongodb://[username:password@]host1[:port1][,host2[:port2],...[,hostN[:portN]]][/[database][?options]] /// e.g. mongodb://localhost:27017/myDatabase /// - /// The options to use for instrumentation. /// - public new virtual MongoDbContextOptionsBuilder UseMongoConnectionString(string connectionString, InstrumentationOptions? instrumentationOptions = null) - => (MongoDbContextOptionsBuilder)base.UseMongoConnectionString(connectionString, instrumentationOptions); + public new virtual MongoDbContextOptionsBuilder UseMongoConnectionString(string connectionString) + => (MongoDbContextOptionsBuilder)base.UseMongoConnectionString(connectionString); /// /// Further configure the existing instance of . diff --git a/src/Tingle.Extensions.MongoDB/Tingle.Extensions.MongoDB.csproj b/src/Tingle.Extensions.MongoDB/Tingle.Extensions.MongoDB.csproj index 7629621..1dfa7d0 100644 --- a/src/Tingle.Extensions.MongoDB/Tingle.Extensions.MongoDB.csproj +++ b/src/Tingle.Extensions.MongoDB/Tingle.Extensions.MongoDB.csproj @@ -16,7 +16,6 @@ -