From 07fa1f567fd54cb909846058d482297fb4b8f042 Mon Sep 17 00:00:00 2001 From: Are Almaas Date: Fri, 13 Dec 2024 14:54:15 +0100 Subject: [PATCH] lele --- .../AspNetUtilitiesExtensions.cs | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/Digdir.Library.Utils.AspNet/AspNetUtilitiesExtensions.cs b/src/Digdir.Library.Utils.AspNet/AspNetUtilitiesExtensions.cs index 4fe656085..c1388ec0d 100644 --- a/src/Digdir.Library.Utils.AspNet/AspNetUtilitiesExtensions.cs +++ b/src/Digdir.Library.Utils.AspNet/AspNetUtilitiesExtensions.cs @@ -141,22 +141,26 @@ public static WebApplicationBuilder ConfigureTelemetry( .AddNpgsql() .AddFusionCacheInstrumentation(); }); - } - else - { - Console.WriteLine("[OpenTelemetry] OTLP exporter not configured - skipping"); - } - if (!string.IsNullOrEmpty(settings.AppInsightsConnectionString)) - { telemetryBuilder.WithMetrics(metrics => { metrics.AddRuntimeInstrumentation() .AddAspNetCoreInstrumentation() - .AddHttpClientInstrumentation() - .AddAzureMonitorMetricExporter(); + .AddHttpClientInstrumentation(); + + if (!string.IsNullOrEmpty(settings.AppInsightsConnectionString)) + { + metrics.AddAzureMonitorMetricExporter(options => + { + options.ConnectionString = settings.AppInsightsConnectionString; + }); + } }); } + else + { + Console.WriteLine("[OpenTelemetry] OTLP exporter not configured - skipping"); + } return builder; }