The .NET runtime exposes multiple metrics through the concept of Event Counters. They were originally introduced in .NET Core as a cross-platform alternative to Performance Counters that only worked on a Windows OS. With the recent introduction of OpenTelemetry support in .NET and the System.Diagnostics.Metrics API, there is a clear path forward. But this doesn’t mean that Event Counters are not useful anymore.
The tooling and ecosystem around it is evolving to support both Event Counters and System.Diagnostics.Metrics. For example, you can see this in action when using the global dotnet-counters tool.
Where I before always used the dotnet-counters tool to monitor the .NET counters, I recently discovered during a debugging session in Visual Studio, that you directly can access this information in the Diagnostics Tools:
- During a debugging session, go to Diagnostics Tools:
- Select the .NET Counters option from the Select Tool dropdown if the Counters are not yet enabled:
- Go to the Counters tab to see the available counters:
That’s it!
More information
Monitor your application using Event Counters–Part I (bartwullems.blogspot.com)
Monitor your application using Event Counters–Part II (bartwullems.blogspot.com)
Monitor your application using Event Counters - Part III (bartwullems.blogspot.com)
Well-known EventCounters in .NET - .NET | Microsoft Learn
dotnet-counters diagnostic tool - .NET CLI - .NET | Microsoft Learn