From 18cb8402e371adf2cb432096b28e466f3cf6e270 Mon Sep 17 00:00:00 2001 From: Robin-Manuel Thiel Date: Sun, 10 Dec 2023 17:32:17 +0100 Subject: [PATCH] Make UseApplicationInsights more explicit --- src/Wemogy.Core/Monitoring/MonitoringEnvironment.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Wemogy.Core/Monitoring/MonitoringEnvironment.cs b/src/Wemogy.Core/Monitoring/MonitoringEnvironment.cs index 4ac1a9d..5a2e3e1 100644 --- a/src/Wemogy.Core/Monitoring/MonitoringEnvironment.cs +++ b/src/Wemogy.Core/Monitoring/MonitoringEnvironment.cs @@ -12,7 +12,7 @@ public class MonitoringEnvironment public string ServiceVersion { get; } public string ApplicationInsightsConnectionString { get; private set; } public float ApplicationInsightsSamplingRatio { get; private set; } - public bool UseApplicationInsights => !string.IsNullOrEmpty(ApplicationInsightsConnectionString); + public bool UseApplicationInsights { get; private set; } public Uri? OtlpExportEndpoint { get; private set; } public bool UseOtlpExporter => OtlpExportEndpoint != null; public bool UsePrometheus { get; private set; } @@ -64,6 +64,7 @@ public MonitoringEnvironment WithApplicationInsights(string connectionString, fl ApplicationInsightsConnectionString = connectionString; ApplicationInsightsSamplingRatio = samplingRatio; + UseApplicationInsights = true; return this; } @@ -79,6 +80,11 @@ public MonitoringEnvironment WithOptionalApplicationInsights(string? connectionS { ApplicationInsightsConnectionString = connectionString; ApplicationInsightsSamplingRatio = samplingRatio; + UseApplicationInsights = true; + } + else + { + UseApplicationInsights = false; } return this;