31
votes

Under Windows, one is able to read .NET performance counters using the following:

  • Performance Monitor
  • C# using PerformanceCounter
  • WMI and querying the .NET related classes

Considering the recent release of .NET Core and the fact that such app can also run in Linux, how can one access the .NET related stats currently available on Windows?

4
I believe it is open source, so you can search at GitHub.Lex Li
there is an "Are perf counters available?" issue: github.com/aspnet/Home/issues/1319Set
There is nothing stopping you from making use of Windows-specific features when you are running on Windows. Sure, querying performance counters won't work when you deploy on Linux, but if you're not deploying on Linux, that's an irrelevant detail. Cross-platform is great, but flexibility is even better. Omitting features to achieve an ideal cross-platform system isn't really progress. You could write the code yourself. Maybe eventually someone will write a module for Linux that implements Windows-style perf counters.Cody Gray
targeting Windows only is not an option as I need to also cover Linux. Writing the code myself is a costly option considering that it requires C and/or C++ skills hence asking this question to clarify if there is any plan by Microsoft to provide a similar method of achieving what we already can do on Windows.MaYaN
Redhat being a contributor, I would like to see some use of Performance Counters for LinuxPhillip Scott Givens

4 Answers

3
votes

This package is exactly equivalent of .NET Framework Performance Counters and can be used in .NET Core apps under Windows:

https://www.nuget.org/packages/System.Diagnostics.PerformanceCounter/

2
votes

In the Windows Compatibility Pack for .NET Core will be support for Performance Counters

https://www.nuget.org/packages/Microsoft.Windows.Compatibility

https://blogs.msdn.microsoft.com/dotnet/2017/11/16/announcing-the-windows-compatibility-pack-for-net-core/

Of course, it is a Windows only feature for now.

1
votes

Performance counters are not in Linux thus not in NET Core. Create another "Full NET based helper application" to expose performance counters as service to "NET Core Application"

0
votes

You can try to use oracle tracing in linux. Before make first connection write this:

OracleConfiguration.TraceFileLocation = "/app/trace";
OracleConfiguration.TraceOption = 0;
OracleConfiguration.TraceLevel = 1;