Exemplo n.º 1
0
        public async Task <IStreamWithCleanup> StartTrace(int pid, TraceProfile profile, TimeSpan duration, int metricsIntervalSeconds, CancellationToken token)
        {
            IList <MonitoringSourceConfiguration> configurations = new List <MonitoringSourceConfiguration>();

            if (profile.HasFlag(TraceProfile.Cpu))
            {
                configurations.Add(new CpuProfileConfiguration());
            }
            if (profile.HasFlag(TraceProfile.Http))
            {
                configurations.Add(new HttpRequestSourceConfiguration());
            }
            if (profile.HasFlag(TraceProfile.Logs))
            {
                configurations.Add(new LoggingSourceConfiguration());
            }
            if (profile.HasFlag(TraceProfile.Metrics))
            {
                configurations.Add(new MetricSourceConfiguration(metricsIntervalSeconds));
            }

            AggregateSourceConfiguration aggregateConfiguration = new AggregateSourceConfiguration(configurations.ToArray());

            DiagnosticsMonitor monitor = new DiagnosticsMonitor(aggregateConfiguration);
            Stream             stream  = await monitor.ProcessEvents(pid, duration, token);

            return(new StreamWithCleanup(monitor, stream));
        }
Exemplo n.º 2
0
        public Task <ActionResult> Trace(
            int?pid,
            [FromQuery] TraceProfile profile = DefaultTraceProfiles,
            [FromQuery][Range(-1, int.MaxValue)] int durationSeconds       = 30,
            [FromQuery][Range(1, int.MaxValue)] int metricsIntervalSeconds = 1)
        {
            TimeSpan duration = ConvertSecondsToTimeSpan(durationSeconds);

            return(InvokeService(async() =>
            {
                var configurations = new List <MonitoringSourceConfiguration>();
                if (profile.HasFlag(TraceProfile.Cpu))
                {
                    configurations.Add(new CpuProfileConfiguration());
                }
                if (profile.HasFlag(TraceProfile.Http))
                {
                    configurations.Add(new HttpRequestSourceConfiguration());
                }
                if (profile.HasFlag(TraceProfile.Logs))
                {
                    configurations.Add(new LoggingSourceConfiguration());
                }
                if (profile.HasFlag(TraceProfile.Metrics))
                {
                    configurations.Add(new MetricSourceConfiguration(metricsIntervalSeconds));
                }

                var aggregateConfiguration = new AggregateSourceConfiguration(configurations.ToArray());

                return await StartTrace(pid, aggregateConfiguration, duration);
            }));
        }
Exemplo n.º 3
0
        public Task <ActionResult> Trace(
            ProcessFilter?processFilter,
            [FromQuery] TraceProfile profile = DefaultTraceProfiles,
            [FromQuery][Range(-1, int.MaxValue)] int durationSeconds       = 30,
            [FromQuery][Range(1, int.MaxValue)] int metricsIntervalSeconds = 1,
            [FromQuery] string egressProvider = null)
        {
            return(InvokeForProcess(processInfo =>
            {
                TimeSpan duration = ConvertSecondsToTimeSpan(durationSeconds);

                var configurations = new List <MonitoringSourceConfiguration>();
                if (profile.HasFlag(TraceProfile.Cpu))
                {
                    configurations.Add(new CpuProfileConfiguration());
                }
                if (profile.HasFlag(TraceProfile.Http))
                {
                    configurations.Add(new HttpRequestSourceConfiguration());
                }
                if (profile.HasFlag(TraceProfile.Logs))
                {
                    configurations.Add(new LoggingSourceConfiguration());
                }
                if (profile.HasFlag(TraceProfile.Metrics))
                {
                    configurations.Add(new MetricSourceConfiguration(metricsIntervalSeconds, Enumerable.Empty <string>()));
                }

                var aggregateConfiguration = new AggregateSourceConfiguration(configurations.ToArray());

                return StartTrace(processInfo, aggregateConfiguration, duration, egressProvider);
            }, processFilter, ArtifactType_Trace));
        }