Performance counters compatibility with .Net Core

Viewed 1196

Is there any nuget packages or helpers for controlling custom performance counters in .Net Core? I'm using System.Diagnostics.PerformanceCounter package.

Visual Studio has PerfWatson2 (Developer Analytics Tools) extension which runs when debugging so I'm able to change counters values.

But if I install that code as a service on that machine and start it, Performance counters values does not change (always zero). Service user is added to "Performance Monitor Users".

If I add service user to "Administrators" group. Then performance counters works.

Maybe "Performance Monitor Users" group is not working with .Net Core? I don't want to run service with admin rights because of performance counters.

Tried Microsoft.Windows.Compatibility nuget package but still no luck.. https://blogs.msdn.microsoft.com/dotnet/2017/11/16/announcing-the-windows-compatibility-pack-for-net-core/

2 Answers

Unfortunately the person who ported the System.Diagnostics.PerformanceCounter nuget package removed the line that set's the correct permissions on the memory mapped file for the perf counters. If you look at SharedPerformanceCounter.Initialize, the original line "sECURITY_ATTRIBUTES.lpSecurityDescriptor = pSecurityDescriptor;" has been removed in the port.

Related