Example #1
0
        public void Should_report_host_metrics(Action <HostMetricsSettings> settingsSetup)
        {
            var settings  = HostMetricsSettings.CreateDisabled();
            var exception = null as Exception;
            var context   = new MetricContext(new MetricContextConfig(new DevNullMetricEventSender())
            {
                ErrorCallback = contextException => exception = contextException
            });

            settingsSetup(settings);
            collector = new HostMetricsCollector(settings);
            collector.ReportMetrics(context, 1.Milliseconds());
            Task.Delay(100).Wait();

            exception.Should().BeNull();
        }
Example #2
0
        private void RegisterHostMonitor(SystemMetricsSettings settings, BuildContext context, IMetricContext metricContext)
        {
            var hostMetricsSettings = settings.HostMetricsSettings;
            var hostMonitor         = new HostMonitor(hostMetricsSettings);

            context.HostExtensions.AsMutable().Add(hostMonitor);

            if (settings.EnableHostMetricsLogging)
            {
                context.RegisterDisposable(hostMonitor.LogPeriodically(context.Log, settings.HostMetricsLoggingPeriod));
            }

            if (settings.EnableHostMetricsReporting)
            {
                var collector = new HostMetricsCollector(hostMetricsSettings);
                context.RegisterDisposable(collector.ReportMetrics(metricContext, settings.HostMetricsReportingPeriod));
                context.RegisterDisposable(collector);
            }

            context.RegisterDisposable(hostMonitor);
        }
Example #3
0
 public void TestSetup()
 {
     collector = new HostMetricsCollector();
     collector.Collect();
 }