From 708336cebf2ef63ce58f091d79dcf5cca916fb89 Mon Sep 17 00:00:00 2001 From: Masterjun3 Date: Tue, 22 Oct 2024 20:37:53 +0200 Subject: [PATCH] add metrics configuration to remove the endpoint histograms and increase precision of db durations --- .../Extensions/ServiceCollectionExtensions.cs | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/TASVideos/Extensions/ServiceCollectionExtensions.cs b/TASVideos/Extensions/ServiceCollectionExtensions.cs index 547615dfb..b78d45c09 100644 --- a/TASVideos/Extensions/ServiceCollectionExtensions.cs +++ b/TASVideos/Extensions/ServiceCollectionExtensions.cs @@ -171,13 +171,26 @@ public static IServiceCollection AddMetrics(this IServiceCollection services, Ap .AddOpenTelemetry() .WithMetrics(builder => { + builder.AddMeter("Microsoft.AspNetCore.Hosting") + .AddView("http.server.request.duration", new ExplicitBucketHistogramConfiguration + { + Boundaries = [] // disable duration histograms of endpoints, which is a LOT of data, but keep total counts + }); + builder.AddMeter( - "Microsoft.AspNetCore.Hosting", "Microsoft.AspNetCore.Server.Kestrel", "Microsoft.AspNetCore.Routing", "Microsoft.AspNetCore.Diagnostics"); - builder.AddMeter("Npgsql"); + builder.AddMeter("Npgsql") + .AddView("db.client.commands.duration", new ExplicitBucketHistogramConfiguration + { + Boundaries = [0.005, 0.01, 0.025, 0.05, 0.075, 0.1, 0.25, 0.5, 0.75, 1, 2.5, 5, 7.5, 10] + }) + .AddView("db.client.connections.create_time", new ExplicitBucketHistogramConfiguration + { + Boundaries = [0.005, 0.01, 0.025, 0.05, 0.075, 0.1, 0.25, 0.5, 0.75, 1, 2.5, 5, 7.5, 10] + }); builder.AddPrometheusExporter(options => {