NullReferenceException in the StandardPerformanceCollector.RegisterPerformanceCounter
- List of NuGet packages and version that you are using: v2.11.2
- Runtime version: net48
- Hosting environment: Windows
Describe the bug
StandardPerformanceCollector.RegisterPerformanceCounter throws NullReferenceException. Here is a code: https://github.com/microsoft/ApplicationInsights-dotnet/blob/main/WEB/Src/PerformanceCollector/PerformanceCollector/Implementation/StandardPerformanceCollector/StandardPerformanceCollector.cs#L270

We are using v2.11.2, the latest version 2.21.0, but the problematic code has not changed. Also, even though NullReferenceException is caught and InvalidOperationException is re-thrown, this is annoying, since when we debug our application we can assume that that NullReferenceException should never be thrown, since it is clear indication of product bug. Also, throwing exception is relatively expensive. Provided screenshot has all the details: parameter names, stack, local variables.
To Reproduce
N/A