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 }
                    }
                });
            }
Esempio n. 2
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 }
                    }
                });
            }
            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 }
                    }
                });
            }