Ejemplo n.º 1
0
        private bool disposedValue = false; // To detect redundant calls

        internal EventPipeSession(IpcEndpoint endpoint, IEnumerable <EventPipeProvider> providers, bool requestRundown, int circularBufferMB)
        {
            _endpoint         = endpoint;
            _providers        = providers;
            _requestRundown   = requestRundown;
            _circularBufferMB = circularBufferMB;

            var config  = new EventPipeSessionConfiguration(circularBufferMB, EventPipeSerializationFormat.NetTrace, providers, requestRundown);
            var message = new IpcMessage(DiagnosticsServerCommandSet.EventPipe, (byte)EventPipeCommandId.CollectTracing2, config.SerializeV2());

            EventStream = IpcClient.SendMessage(endpoint, message, out var response);
            switch ((DiagnosticsServerResponseId)response.Header.CommandId)
            {
            case DiagnosticsServerResponseId.OK:
                _sessionId = BitConverter.ToInt64(response.Payload, 0);
                break;

            case DiagnosticsServerResponseId.Error:
                var hr = BitConverter.ToInt32(response.Payload, 0);
                throw new ServerErrorException($"EventPipe session start failed (HRESULT: 0x{hr:X8})");

            default:
                throw new ServerErrorException($"EventPipe session start failed - Server responded with unknown command");
            }
        }
Ejemplo n.º 2
0
        private static IpcMessage CreateStartMessage(IEnumerable <EventPipeProvider> providers, bool requestRundown, int circularBufferMB)
        {
            var config = new EventPipeSessionConfiguration(circularBufferMB, EventPipeSerializationFormat.NetTrace, providers, requestRundown);

            return(new IpcMessage(DiagnosticsServerCommandSet.EventPipe, (byte)EventPipeCommandId.CollectTracing2, config.SerializeV2()));
        }