Uh oh!
There was an error while loading. Please reload this page.
Fixes issue when monitoring a process launched via the same command line - #76965
Conversation
ghost
commented
Oct 12, 2022
Tagging subscribers to this area: @tarekgh, @tommcdon, @pjanotti Issue DetailsFixes dotnet/diagnostics#3366. A NullReferenceException was being thrown and caught because the CommandHandler in MetricsEventSource was being referenced before being initialized. Now custom metrics are displayed when trying to monitor a process in the same command line. Here is example output for a simple application with a custom meter that displays random values:
|
noahfalk
commented
Oct 13, 2022
Can you include the callstack where the NullReferenceException occurs? A lot of the changes were swapping the Log property to a local parent field so does that also mean the static Log property was not initialized at that point? I want to understand what constraints we are working within :) |
@noahfalk we're trying to grab the original exception but running in to technical difficulties. The reason it fails is if you start a session before the runtime starts, you see the following scenario
|
noahfalk
commented
Oct 13, 2022
Got it. What if we did something like this?
privateCommandHandlerHandler{get{if(_handler==null){Interlocked.CompareExchange(ref_handler,newCommandHandler(this),null);}returnhandler;}
publicCommandHandler(MetricsEventSource parent){Parent=parent;}publicMetricsEventSourceParent{get;}// some code that needs to use parentParent.Error("Something bad happened"); |
davmason
commented
Oct 13, 2022
Works for me |
Fixesdotnet/diagnostics#3366. A NullReferenceException was being thrown and caught because the CommandHandler in MetricsEventSource was being referenced before being initialized. Now custom metrics are displayed when trying to monitor a process in the same command line. Here is example output for a simple application with a custom meter that displays random values:
Running
dotnet-counters monitor --counters System.Runtime,demo_meter -- countersbug.exewill now output:Running
dotnet-counters monitor --counters demo_meter -- countersbug.exewill now output: