コード例 #1
0
        private async Task <ActionResult> StartTrace(
            ProcessFilter?processFilter,
            MonitoringSourceConfiguration configuration,
            TimeSpan duration)
        {
            IProcessInfo processInfo = await _diagnosticServices.GetProcessAsync(processFilter, HttpContext.RequestAborted);

            return(new OutputStreamResult(async(outputStream, token) =>
            {
                Func <Stream, CancellationToken, Task> streamAvailable = async(Stream eventStream, CancellationToken token) =>
                {
                    //Buffer size matches FileStreamResult
                    //CONSIDER Should we allow client to change the buffer size?
                    await eventStream.CopyToAsync(outputStream, 0x10000, token);
                };

                await using EventTracePipeline pipeProcessor = new EventTracePipeline(processInfo.Client, new EventTracePipelineSettings
                {
                    Configuration = configuration,
                    Duration = duration,
                }, streamAvailable);

                await pipeProcessor.RunAsync(token);
            }, "application/octet-stream", FormattableString.Invariant($"{GetFileNameTimeStampUtcNow()}_{processInfo.ProcessId}.nettrace")));
        }
コード例 #2
0
        public static async Task CaptureTraceAsync(TaskCompletionSource <object> startCompletionSource, IEndpointInfo endpointInfo, MonitoringSourceConfiguration configuration, TimeSpan duration, Stream outputStream, CancellationToken token)
        {
            Func <Stream, CancellationToken, Task> streamAvailable = async(Stream eventStream, CancellationToken token) =>
            {
                if (null != startCompletionSource)
                {
                    startCompletionSource.TrySetResult(null);
                }
                //Buffer size matches FileStreamResult
                //CONSIDER Should we allow client to change the buffer size?
                await eventStream.CopyToAsync(outputStream, 0x10000, token);
            };

            var client = new DiagnosticsClient(endpointInfo.Endpoint);

            await using EventTracePipeline pipeProcessor = new EventTracePipeline(client, new EventTracePipelineSettings
            {
                Configuration = configuration,
                Duration      = duration,
            }, streamAvailable);

            await pipeProcessor.RunAsync(token);
        }
コード例 #3
0
        private async Task <ActionResult> StartTrace(
            ProcessFilter?processFilter,
            MonitoringSourceConfiguration configuration,
            TimeSpan duration,
            string egressProvider)
        {
            IProcessInfo processInfo = await _diagnosticServices.GetProcessAsync(processFilter, HttpContext.RequestAborted);

            string fileName = FormattableString.Invariant($"{GetFileNameTimeStampUtcNow()}_{processInfo.EndpointInfo.ProcessId}.nettrace");

            Func <Stream, CancellationToken, Task> action = async(outputStream, token) =>
            {
                Func <Stream, CancellationToken, Task> streamAvailable = async(Stream eventStream, CancellationToken token) =>
                {
                    //Buffer size matches FileStreamResult
                    //CONSIDER Should we allow client to change the buffer size?
                    await eventStream.CopyToAsync(outputStream, 0x10000, token);
                };

                var client = new DiagnosticsClient(processInfo.EndpointInfo.Endpoint);

                await using EventTracePipeline pipeProcessor = new EventTracePipeline(client, new EventTracePipelineSettings
                {
                    Configuration = configuration,
                    Duration      = duration,
                }, streamAvailable);

                await pipeProcessor.RunAsync(token);
            };

            return(Result(
                       egressProvider,
                       action,
                       fileName,
                       ContentTypes.ApplicationOctectStream,
                       processInfo.EndpointInfo));
        }