protected override async Task <CollectionRuleActionResult> ExecuteCoreAsync(
                TaskCompletionSource <object> startCompleteSource,
                CancellationToken token)
            {
                string egress = Options.Egress;

                string gcdumpFileName = GCDumpUtilities.GenerateGCDumpFileName(EndpointInfo);

                KeyValueLogScope scope = Utils.CreateArtifactScope(Utils.ArtifactType_GCDump, EndpointInfo);

                EgressOperation egressOperation = new EgressOperation(
                    (stream, token) =>
                {
                    startCompleteSource.TrySetResult(null);
                    return(GCDumpUtilities.CaptureGCDumpAsync(EndpointInfo, stream, token));
                },
                    egress,
                    gcdumpFileName,
                    EndpointInfo,
                    ContentTypes.ApplicationOctetStream,
                    scope);

                ExecutionResult <EgressResult> result = await egressOperation.ExecuteAsync(_serviceProvider, token);

                string gcdumpFilePath = result.Result.Value;

                return(new CollectionRuleActionResult()
                {
                    OutputValues = new Dictionary <string, string>(StringComparer.Ordinal)
                    {
                        { CollectionRuleActionConstants.EgressPathOutputValueName, gcdumpFilePath }
                    }
                });
            }
            protected override async Task <CollectionRuleActionResult> ExecuteCoreAsync(
                TaskCompletionSource <object> startCompletionSource,
                CancellationToken token)
            {
                TimeSpan duration       = Options.Duration.GetValueOrDefault(TimeSpan.Parse(CollectTraceOptionsDefaults.Duration));
                string   egressProvider = Options.Egress;

                MonitoringSourceConfiguration configuration;

                if (Options.Profile.HasValue)
                {
                    TraceProfile profile = Options.Profile.Value;
                    float        metricsIntervalSeconds = _counterOptions.CurrentValue.GetIntervalSeconds();

                    configuration = TraceUtilities.GetTraceConfiguration(profile, metricsIntervalSeconds);
                }
                else
                {
                    EventPipeProvider[] optionsProviders = Options.Providers.ToArray();
                    bool requestRundown      = Options.RequestRundown.GetValueOrDefault(CollectTraceOptionsDefaults.RequestRundown);
                    int  bufferSizeMegabytes = Options.BufferSizeMegabytes.GetValueOrDefault(CollectTraceOptionsDefaults.BufferSizeMegabytes);

                    configuration = TraceUtilities.GetTraceConfiguration(optionsProviders, requestRundown, bufferSizeMegabytes);
                }

                string fileName = TraceUtilities.GenerateTraceFileName(EndpointInfo);

                KeyValueLogScope scope = Utils.CreateArtifactScope(Utils.ArtifactType_Trace, EndpointInfo);

                EgressOperation egressOperation = new EgressOperation(
                    async(outputStream, token) =>
                {
                    using IDisposable operationRegistration = _operationTrackerService.Register(EndpointInfo);
                    await TraceUtilities.CaptureTraceAsync(startCompletionSource, EndpointInfo, configuration, duration, outputStream, token);
                },
                    egressProvider,
                    fileName,
                    EndpointInfo,
                    ContentTypes.ApplicationOctetStream,
                    scope);

                ExecutionResult <EgressResult> result = await egressOperation.ExecuteAsync(_serviceProvider, token);

                string traceFilePath = result.Result.Value;

                return(new CollectionRuleActionResult()
                {
                    OutputValues = new Dictionary <string, string>(StringComparer.Ordinal)
                    {
                        { CollectionRuleActionConstants.EgressPathOutputValueName, traceFilePath }
                    }
                });
            }
예제 #3
0
            protected override async Task <CollectionRuleActionResult> ExecuteCoreAsync(
                TaskCompletionSource <object> startCompletionSource,
                CancellationToken token)
            {
                TimeSpan duration      = Options.Duration.GetValueOrDefault(TimeSpan.Parse(CollectLogsOptionsDefaults.Duration));
                bool     useAppFilters = Options.UseAppFilters.GetValueOrDefault(CollectLogsOptionsDefaults.UseAppFilters);
                LogLevel defaultLevel  = Options.DefaultLevel.GetValueOrDefault(CollectLogsOptionsDefaults.DefaultLevel);
                Dictionary <string, LogLevel?> filterSpecs = Options.FilterSpecs;
                string    egressProvider = Options.Egress;
                LogFormat logFormat      = Options.Format.GetValueOrDefault(CollectLogsOptionsDefaults.Format);

                var settings = new EventLogsPipelineSettings()
                {
                    Duration      = duration,
                    LogLevel      = defaultLevel,
                    UseAppFilters = useAppFilters,
                    FilterSpecs   = filterSpecs
                };

                string fileName    = LogsUtilities.GenerateLogsFileName(EndpointInfo);
                string contentType = LogsUtilities.GetLogsContentType(logFormat);

                KeyValueLogScope scope = Utils.CreateArtifactScope(Utils.ArtifactType_Logs, EndpointInfo);

                EgressOperation egressOperation = new EgressOperation(
                    (outputStream, token) => LogsUtilities.CaptureLogsAsync(startCompletionSource, logFormat, EndpointInfo, settings, outputStream, token),
                    egressProvider,
                    fileName,
                    EndpointInfo,
                    contentType,
                    scope);

                ExecutionResult <EgressResult> result = await egressOperation.ExecuteAsync(_serviceProvider, token);

                string logsFilePath = result.Result.Value;

                return(new CollectionRuleActionResult()
                {
                    OutputValues = new Dictionary <string, string>(StringComparer.Ordinal)
                    {
                        { CollectionRuleActionConstants.EgressPathOutputValueName, logsFilePath }
                    }
                });
            }
예제 #4
0
            protected override async Task <CollectionRuleActionResult> ExecuteCoreAsync(
                TaskCompletionSource <object> startCompletionSource,
                CancellationToken token)
            {
                DumpType dumpType       = Options.Type.GetValueOrDefault(CollectDumpOptionsDefaults.Type);
                string   egressProvider = Options.Egress;

                string dumpFileName = DumpUtilities.GenerateDumpFileName();

                string dumpFilePath = string.Empty;

                KeyValueLogScope scope = Utils.CreateArtifactScope(Utils.ArtifactType_Dump, EndpointInfo);

                try
                {
                    EgressOperation egressOperation = new EgressOperation(
                        token => {
                        startCompletionSource.TrySetResult(null);
                        return(_dumpService.DumpAsync(EndpointInfo, dumpType, token));
                    },
                        egressProvider,
                        dumpFileName,
                        EndpointInfo,
                        ContentTypes.ApplicationOctetStream,
                        scope);

                    ExecutionResult <EgressResult> result = await egressOperation.ExecuteAsync(_serviceProvider, token);

                    dumpFilePath = result.Result.Value;
                }
                catch (Exception ex)
                {
                    throw new CollectionRuleActionException(ex);
                }

                return(new CollectionRuleActionResult()
                {
                    OutputValues = new Dictionary <string, string>(StringComparer.Ordinal)
                    {
                        { CollectionRuleActionConstants.EgressPathOutputValueName, dumpFilePath }
                    }
                });
            }