示例#1
0
        private void RegisterProcessMonitor(SystemMetricsSettings settings, BuildContext context, IMetricContext metricContext)
        {
            var processMonitor = new CurrentProcessMonitor();

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

            if (settings.EnableProcessMetricsLogging)
            {
                context.RegisterDisposable(processMonitor.LogPeriodically(context.Log, settings.ProcessMetricsLoggingPeriod));
            }

            if (settings.EnableProcessMetricsReporting)
            {
                var collectorSettings = new CurrentProcessMetricsSettings
                {
                    CpuCoresLimitProvider    = () => context.ApplicationLimits.CpuUnits,
                    MemoryBytesLimitProvider = () => context.ApplicationLimits.MemoryBytes
                };

                var collector = new CurrentProcessMetricsCollector(collectorSettings);
                context.RegisterDisposable(collector.ReportMetrics(metricContext, settings.ProcessMetricsReportingPeriod));
                context.RegisterDisposable(collector);
            }

            context.RegisterDisposable(processMonitor);
        }
示例#2
0
        private void RegisterDnsMonitor(SystemMetricsSettings settings, BuildContext context, IMetricContext metricContext)
        {
            var dnsMonitor = new DnsMonitor();

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

            if (settings.EnableDnsEventsMetrics)
            {
                context.RegisterDisposable(dnsMonitor.ReportMetrics(metricContext, settings.ProcessMetricsReportingPeriod));
            }

            context.RegisterDisposable(dnsMonitor);
        }
示例#3
0
        private void RegisterHostMonitor(SystemMetricsSettings settings, BuildContext context, IMetricContext metricContext)
        {
            var hostMonitor = new HostMonitor();

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

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

            if (settings.EnableHostMetricsReporting)
            {
                new HostMetricsCollector().ReportMetrics(metricContext);
            }
        }
示例#4
0
        private void RegisterGcMonitor(SystemMetricsSettings settings, BuildContext context, IMetricContext metricContext)
        {
            var gcMonitor = new GarbageCollectionMonitor();

            context.HostExtensions.AsMutable().Add(gcMonitor);
            context.DisposableHostExtensions.Add(gcMonitor);

            if (settings.EnableGcEventsLogging)
            {
                context.DisposableHostExtensions.Add(gcMonitor.LogCollections(context.Log, gc => gc.Duration >= settings.GcMinimumDurationForLogging));
            }

            if (settings.EnableGcEventsMetrics)
            {
                context.DisposableHostExtensions.Add(gcMonitor.ReportMetrics(metricContext));
            }
        }