Description
The current implementation of HttpRequestLatencyListener.OnEventWritten always expects that eventSourceName should be available in the _eventToTokenMap dictionary.
Certain events (e.g., EventCounters) bypass the enabled events check, which results in OnEventWritten throwing a KeyNotFoundException.
Example
The "EventCounters" event from the source "System.Runtime" is sent to all listeners and skips the enabled event check since its eventId is -1.
https://github.com/dotnet/runtime/blob/ac8354e3e94f04fae2d6d942427d025395197f76/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/EventSource.cs#L2187
Impact
KeyNotFoundExceptions from HttpRequestLatencyListener cause each HTTP request to be 2-3 times slower.