From 89d6e747ecaf656a84c4304ce3f1630a3b0cdaee Mon Sep 17 00:00:00 2001 From: David Fowler Date: Sat, 5 Nov 2022 08:44:35 -0700 Subject: [PATCH] Remove the event listener --- .../Podcast.MinimalAPI/OtelListener.cs | 38 ------------------- 1 file changed, 38 deletions(-) delete mode 100644 src/Services/Podcasts/Podcast.MinimalAPI/OtelListener.cs diff --git a/src/Services/Podcasts/Podcast.MinimalAPI/OtelListener.cs b/src/Services/Podcasts/Podcast.MinimalAPI/OtelListener.cs deleted file mode 100644 index a857572..0000000 --- a/src/Services/Podcasts/Podcast.MinimalAPI/OtelListener.cs +++ /dev/null @@ -1,38 +0,0 @@ -using System.Collections.Concurrent; -using System.Diagnostics.Tracing; - -// Just for debugging things -class OtelListener : EventListener -{ - public static ILoggerFactory _factory; - private ConcurrentDictionary _loggerMap = new(); - - public OtelListener() - { - - } - - protected override void OnEventSourceCreated(EventSource eventSource) - { - if (eventSource.Name.StartsWith("OpenTelemetry")) - { - if (_loggerMap.TryGetValue(eventSource.Name, out _)) return; - ILogger CreateAndRegister(string name) - { - var l = _factory.CreateLogger(name); - base.EnableEvents(eventSource, EventLevel.LogAlways, EventKeywords.All); - return l; - } - var logger = _loggerMap.AddOrUpdate(eventSource.Name, CreateAndRegister, (name, existing) => existing); - } - base.OnEventSourceCreated(eventSource); - } - - protected override void OnEventWritten(EventWrittenEventArgs eventData) - { - if (_loggerMap[eventData.EventSource.Name] is { } logger) - { - logger.Log(LogLevel.Information, eventData.Message, (eventData.Payload?.ToArray() ?? Array.Empty())); - } - } -} \ No newline at end of file