/// <summary>
        /// Adds a hosted service which collects system metrics such as CPU usage and memory working set.
        /// </summary>
        public static IServiceCollection AddAppMetricsSystemMetricsCollector(
            this IServiceCollection services,
            Action <MetricsSystemUsageCollectorOptions> optionsSetup = null)
        {
            var options = new MetricsSystemUsageCollectorOptions();

            optionsSetup?.Invoke(options);
            services.AddSingleton(options);

            return(services.AddHostedService <SystemUsageCollectorHostedService>());
        }
コード例 #2
0
 public SystemUsageCollectorHostedService(IMetrics metrics, MetricsSystemUsageCollectorOptions options)
 {
     _metrics       = metrics;
     _options       = options;
     _lastTimeStamp = _process.StartTime;
 }