Skip to content

Commit

Permalink
Workaround EventListener bug when consuming metrics (#2104)
Browse files Browse the repository at this point in the history
  • Loading branch information
MihaZupan authored Apr 18, 2023
1 parent 4004860 commit 05074ac
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/TelemetryConsumption/EventListenerService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,14 @@ private void OnNonUserEvent(EventWrittenEventArgs eventData)
{
if (eventData.EventId == -1)
{
if (!ReferenceEquals(eventData.EventSource, _eventSource))
{
// Workaround for https://github.com/dotnet/runtime/issues/31927
// EventCounters are published to all EventListeners, regardless of
// which EventSource providers a listener is enabled for.
return;
}

// Throwing an exception here would crash the process
if (eventData.EventName != "EventCounters" ||
eventData.Payload?.Count != 1 ||
Expand Down

0 comments on commit 05074ac

Please sign in to comment.