.NET Core performance counters

141 views Asked by At

I have a .net core service running on windows. In the performance monitor tool I could find counters such as "\Process(MyServiceName)\% Processor Time" but not others like "\.NET CLR LocksAndThreads(MyServiceName)\*"

how to find which .net core counters are supported by the perfmon? I need to get the "\.NET CLR LocksAndThreads(MyServiceName)\*" for my service, any idea how to do it?

1

There are 1 answers

0
Denis Micheal On BEST ANSWER

Diagnose and solve performance problems in net-core

Unlike the .NET Framework on Windows, .NET Core doesn’t emit perf counters. Instead, we had introduced a new way of emitting metrics in .NET Core via the EventCounter API.

EventCounters offer an improvement over Windows perf counters as these are now usable on all OSes where .NET Core is supported.

EventCounters

EventCounters are .NET APIs used for lightweight, cross-platform, and near real-time performance metric collection. EventCounters were added as a cross-platform alternative to the "performance counters" of .NET Framework on Windows.

You can use these performance diagnostic tools designed for .NET Core :


Example Usage of dotnet-counters:

  1. Install the tool

    dotnet tool install --global dotnet-counters

  2. Run command below to make dotnet-counters create a diagnostics socket named myport.sock and wait for a connection.

    dotnet-counters collect --diagnostic-port myport.sock

  3. Set DOTNET_DiagnosticPorts=myport.sock in your application's environment variables which will enable dotnet-counters to start collecting counters on your app and run your app.

Output of the command in 2:

enter image description here


By default dotnet-counters will collect/monitor the Well-known EventCounters, The counters I believe you are specifically interested in are the System.Runtime counters i.e Monitor Lock Contention Count,ThreadPool Queue Length and ThreadPool Thread Count (These are monitored/collected by default).