Beispiel #1
0
        public static MonitoringSourceConfiguration GetTraceConfiguration(Models.TraceProfile profile, float metricsIntervalSeconds)
        {
            var configurations = new List <MonitoringSourceConfiguration>();

            if (profile.HasFlag(Models.TraceProfile.Cpu))
            {
                configurations.Add(new CpuProfileConfiguration());
            }
            if (profile.HasFlag(Models.TraceProfile.Http))
            {
                configurations.Add(new HttpRequestSourceConfiguration());
            }
            if (profile.HasFlag(Models.TraceProfile.Logs))
            {
                configurations.Add(new LoggingSourceConfiguration(
                                       LogLevel.Trace,
                                       LogMessageType.FormattedMessage | LogMessageType.JsonMessage,
                                       filterSpecs: null,
                                       useAppFilters: true));
            }
            if (profile.HasFlag(Models.TraceProfile.Metrics))
            {
                configurations.Add(new MetricSourceConfiguration(metricsIntervalSeconds, Enumerable.Empty <string>()));
            }

            return(new AggregateSourceConfiguration(configurations.ToArray()));
        }
        public Task <ActionResult> CaptureTrace(
            ProcessKey?processKey,
            [FromQuery]
            Models.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(Models.TraceProfile.Cpu))
                {
                    configurations.Add(new CpuProfileConfiguration());
                }
                if (profile.HasFlag(Models.TraceProfile.Http))
                {
                    configurations.Add(new HttpRequestSourceConfiguration());
                }
                if (profile.HasFlag(Models.TraceProfile.Logs))
                {
                    configurations.Add(new LoggingSourceConfiguration());
                }
                if (profile.HasFlag(Models.TraceProfile.Metrics))
                {
                    configurations.Add(new MetricSourceConfiguration(metricsIntervalSeconds, Enumerable.Empty <string>()));
                }

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

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