From 1ba85f6367b33754891b9a73813dddb5173e098e Mon Sep 17 00:00:00 2001 From: Koen Metsu Date: Mon, 9 Dec 2024 11:40:01 +0100 Subject: [PATCH] feat: or-2605 add marten/wolverine metrics --- AssociationRegistry.sln | 1 + .../Infrastructure/Extensions/MartenExtensions.cs | 3 +++ .../Infrastructure/Extensions/WolverineExtensions.cs | 7 ------- .../WebApplicationBuilder/ConfigureMartenExtensions.cs | 3 +++ .../Extensions/ServiceCollectionExtensions.cs | 4 ++++ 5 files changed, 11 insertions(+), 7 deletions(-) diff --git a/AssociationRegistry.sln b/AssociationRegistry.sln index 83d575ed6..a8d1b4ea3 100644 --- a/AssociationRegistry.sln +++ b/AssociationRegistry.sln @@ -21,6 +21,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".Solution Items", ".Solutio CONTRIBUTING.md = CONTRIBUTING.md regen-marten.sh = regen-marten.sh paket.lock = paket.lock + otel-collector-config.yaml = otel-collector-config.yaml EndProjectSection EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{C812C887-6495-405A-8B99-4F686D243126}" diff --git a/src/AssociationRegistry.Admin.Api/Infrastructure/Extensions/MartenExtensions.cs b/src/AssociationRegistry.Admin.Api/Infrastructure/Extensions/MartenExtensions.cs index e33c9aa7e..f2abaa289 100644 --- a/src/AssociationRegistry.Admin.Api/Infrastructure/Extensions/MartenExtensions.cs +++ b/src/AssociationRegistry.Admin.Api/Infrastructure/Extensions/MartenExtensions.cs @@ -41,6 +41,9 @@ public static IServiceCollection AddMarten( opts.DatabaseSchemaName = postgreSqlOptions.Schema; } + opts.OpenTelemetry.TrackConnections = TrackLevel.Normal; + opts.OpenTelemetry.TrackEventCounters(); + opts.Connection(postgreSqlOptions.GetConnectionString()); opts.Storage.Add(new VCodeSequence(opts, VCode.StartingVCode)); opts.Serializer(CreateCustomMartenSerializer()); diff --git a/src/AssociationRegistry.Admin.Api/Infrastructure/Extensions/WolverineExtensions.cs b/src/AssociationRegistry.Admin.Api/Infrastructure/Extensions/WolverineExtensions.cs index ce9abdde2..19d7cfe7a 100644 --- a/src/AssociationRegistry.Admin.Api/Infrastructure/Extensions/WolverineExtensions.cs +++ b/src/AssociationRegistry.Admin.Api/Infrastructure/Extensions/WolverineExtensions.cs @@ -1,22 +1,16 @@ namespace AssociationRegistry.Admin.Api.Infrastructure.Extensions; using Acties.GrarConsumer; -using Acties.GrarConsumer.HeradresseerLocaties; -using Acties.GrarConsumer.OntkoppelAdres; using Amazon.Runtime; using EventStore; using Grar.AddressMatch; using Hosts.Configuration; using JasperFx.CodeGeneration; using Serilog; -using System.Text.Encodings.Web; -using System.Text.Json; -using System.Text.Json.Serialization; using Vereniging; using Wolverine; using Wolverine.AmazonSqs; using Wolverine.ErrorHandling; -using Wolverine.Runtime.Serialization; public static class WolverineExtensions { @@ -26,7 +20,6 @@ public static void AddWolverine(this WebApplicationBuilder builder) (context, options) => { Log.Logger.Information("Setting up wolverine"); - options.ApplicationAssembly = typeof(Program).Assembly; options.Discovery.IncludeAssembly(typeof(Vereniging).Assembly); options.Discovery.IncludeType(); diff --git a/src/AssociationRegistry.Admin.ProjectionHost/Infrastructure/Program/WebApplicationBuilder/ConfigureMartenExtensions.cs b/src/AssociationRegistry.Admin.ProjectionHost/Infrastructure/Program/WebApplicationBuilder/ConfigureMartenExtensions.cs index c9435c3e6..998556afe 100644 --- a/src/AssociationRegistry.Admin.ProjectionHost/Infrastructure/Program/WebApplicationBuilder/ConfigureMartenExtensions.cs +++ b/src/AssociationRegistry.Admin.ProjectionHost/Infrastructure/Program/WebApplicationBuilder/ConfigureMartenExtensions.cs @@ -89,6 +89,9 @@ static JsonNetSerializer CreateCustomMartenSerializer() opts.Connection(connectionString); + opts.OpenTelemetry.TrackConnections = TrackLevel.Normal; + opts.OpenTelemetry.TrackEventCounters(); + opts.Events.StreamIdentity = StreamIdentity.AsString; opts.Events.MetadataConfig.EnableAll(); diff --git a/src/AssociationRegistry.OpenTelemetry/Extensions/ServiceCollectionExtensions.cs b/src/AssociationRegistry.OpenTelemetry/Extensions/ServiceCollectionExtensions.cs index 5919be652..53c3dd1cf 100644 --- a/src/AssociationRegistry.OpenTelemetry/Extensions/ServiceCollectionExtensions.cs +++ b/src/AssociationRegistry.OpenTelemetry/Extensions/ServiceCollectionExtensions.cs @@ -1,6 +1,7 @@ namespace AssociationRegistry.OpenTelemetry.Extensions; using Destructurama; +using global::OpenTelemetry; using global::OpenTelemetry.Exporter; using global::OpenTelemetry.Metrics; using global::OpenTelemetry.Resources; @@ -82,6 +83,9 @@ public static IServiceCollection ConfigureOpenTelemetry(this IHostApplication return services.AddOpenTelemetry() .ConfigureResource(configureResource) .WithMetrics(providerBuilder => providerBuilder + .ConfigureResource(configureResource) + .AddMeter($"Wolverine:{serviceName}") + .AddMeter("Marten") .AddRuntimeInstrumentation() .AddAspNetCoreInstrumentation() .AddHttpClientInstrumentation()