From d7d80e863b3bc9c274f65890b35582439f0d420a Mon Sep 17 00:00:00 2001 From: Enkidu93 Date: Wed, 20 Sep 2023 17:09:01 -0400 Subject: [PATCH] Added Mongo instrumentation --- src/SIL.DataAccess/IServiceCollectionExtensions.cs | 1 + src/SIL.DataAccess/SIL.DataAccess.csproj | 1 + src/SIL.DataAccess/Usings.cs | 1 + src/Serval.ApiServer/Startup.cs | 1 + 4 files changed, 4 insertions(+) diff --git a/src/SIL.DataAccess/IServiceCollectionExtensions.cs b/src/SIL.DataAccess/IServiceCollectionExtensions.cs index d3d950df..33e5cb8f 100644 --- a/src/SIL.DataAccess/IServiceCollectionExtensions.cs +++ b/src/SIL.DataAccess/IServiceCollectionExtensions.cs @@ -32,6 +32,7 @@ Action configure services.Configure(options => options.Url = new MongoUrl(connectionString)); services.AddTransient(); var clientSettings = MongoClientSettings.FromConnectionString(connectionString); + clientSettings.ClusterConfigurator = cb => cb.Subscribe(new DiagnosticsActivityEventSubscriber()); clientSettings.LinqProvider = LinqProvider.V2; services.AddSingleton(sp => new MongoClient(clientSettings)); services.AddSingleton( diff --git a/src/SIL.DataAccess/SIL.DataAccess.csproj b/src/SIL.DataAccess/SIL.DataAccess.csproj index 3631ac89..21827fcf 100644 --- a/src/SIL.DataAccess/SIL.DataAccess.csproj +++ b/src/SIL.DataAccess/SIL.DataAccess.csproj @@ -14,6 +14,7 @@ + diff --git a/src/SIL.DataAccess/Usings.cs b/src/SIL.DataAccess/Usings.cs index fb4848bb..63eb16a9 100644 --- a/src/SIL.DataAccess/Usings.cs +++ b/src/SIL.DataAccess/Usings.cs @@ -13,6 +13,7 @@ global using MongoDB.Bson.Serialization; global using MongoDB.Bson.Serialization.Conventions; global using MongoDB.Bson.Serialization.Serializers; +global using MongoDB.Driver.Core.Extensions.DiagnosticSources; global using MongoDB.Driver; global using MongoDB.Driver.Linq; global using Nito.AsyncEx; diff --git a/src/Serval.ApiServer/Startup.cs b/src/Serval.ApiServer/Startup.cs index 6b86e760..447962d8 100644 --- a/src/Serval.ApiServer/Startup.cs +++ b/src/Serval.ApiServer/Startup.cs @@ -164,6 +164,7 @@ public void ConfigureServices(IServiceCollection services) { builder.AddAspNetCoreInstrumentation().AddConsoleExporter(); builder.AddHttpClientInstrumentation().AddConsoleExporter(); + builder.AddSource("MongoDB.Driver.Core.Extensions.DiagnosticSources").AddConsoleExporter(); }); }