From 8b5e4973ea02c7551b08fb5ddf753abbb910dbab Mon Sep 17 00:00:00 2001 From: Robin-Manuel Thiel Date: Mon, 27 Nov 2023 23:37:00 +0100 Subject: [PATCH] Add WithActivitySource() to Monitoring Environment --- src/Wemogy.Core/Monitoring/MonitoringEnvironment.cs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/Wemogy.Core/Monitoring/MonitoringEnvironment.cs b/src/Wemogy.Core/Monitoring/MonitoringEnvironment.cs index 7532461..58d06ed 100644 --- a/src/Wemogy.Core/Monitoring/MonitoringEnvironment.cs +++ b/src/Wemogy.Core/Monitoring/MonitoringEnvironment.cs @@ -17,6 +17,7 @@ public class MonitoringEnvironment public bool UseOtlpExporter => OtlpExportEndpoint != null; public bool UsePrometheus { get; private set; } public HashSet MeterNames { get; private set; } + public HashSet ActivitySourceNames { get; private set; } public MonitoringEnvironment() { @@ -29,6 +30,7 @@ public MonitoringEnvironment() UsePrometheus = false; OtlpExportEndpoint = null; MeterNames = new HashSet(); + ActivitySourceNames = new HashSet(); } public MonitoringEnvironment(string serviceName, string serviceVersion) @@ -79,5 +81,15 @@ public MonitoringEnvironment WithMeter(string meterName) MeterNames.Add(meterName); return this; } + + /// + /// Registers a System.Diagnostics.ActivitySource at the environment. The activity source itself has to be created outside the environment. + /// + /// Name of the activity source + public MonitoringEnvironment WithActivitySource(string activitySourceName) + { + ActivitySourceNames.Add(activitySourceName); + return this; + } } }