Is it possible for a .NET process to be started without Event Counters?

60 Views Asked by At

I have an app that attempts to establish an EventPipe session with some .NET Core processes in order to get an access to their Event Counters.

The code uses Microsoft.Diagnostics.NETCore.Client:

    var processId = ...; // guaranteed to exist
    var providers = new List<EventPipeProvider>()
    {
        new EventPipeProvider(
            "System.Runtime",
            EventLevel.Informational,
            (long)ClrTraceEventParser.Keywords.None,
            new Dictionary<string, string>() {
                { "EventCounterIntervalSec", "1" }
            }
        )
    };
    var client = new DiagnosticsClient(processId);
    using(var session = client.StartEventPipeSession(providers))
    {
        // ..
    }

It works fine in most of the cases, but sometimes the call to StartEventPipeSession hangs and times out. Retrying doesn't help. However, the process, which refuses to have an EventPipe Session connected, looks pretty normal apart from that and it works as expected.

Is it possible for a .NET Core process to be started without Event Counters?

I use Windows 10.

EDIT

As suggested in the comments, here's an exception message that I get from StartEventPipeSession. Nothing too fancy, just a timeout, but I post it here for completeness.

EXCEPTION: System.TimeoutException: The operation has timed out.
   at System.IO.Pipes.NamedPipeClientStream.ConnectInternal(Int32 timeout, CancellationToken cancellationToken, Int32 startTime)
   at Microsoft.Diagnostics.NETCore.Client.IpcEndpointHelper.Connect(IpcEndpointConfig config, TimeSpan timeout)
   at Microsoft.Diagnostics.NETCore.Client.PidIpcEndpoint.Connect(TimeSpan timeout)
   at Microsoft.Diagnostics.NETCore.Client.IpcClient.SendMessageGetContinuation(IpcEndpoint endpoint, IpcMessage message)
   at Microsoft.Diagnostics.NETCore.Client.EventPipeSession.Start(IpcEndpoint endpoint, EventPipeSessionConfiguration config)
   at Microsoft.Diagnostics.NETCore.Client.DiagnosticsClient.StartEventPipeSession(IEnumerable`1 providers, Boolean requestRundown, Int32 circularBufferMB)
0

There are 0 best solutions below