ApplicationInsights-dotnet icon indicating copy to clipboard operation
ApplicationInsights-dotnet copied to clipboard

NullReferenceException in the StandardPerformanceCollector.RegisterPerformanceCounter

Open VladimirKhvostov opened this issue 3 years ago • 0 comments

  • 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

image

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

VladimirKhvostov avatar Aug 28 '22 17:08 VladimirKhvostov