/// <summary>
        /// Adds a hosted service which collects GC events using the "Microsoft-Windows-DotNETRuntime" EventSource.
        /// </summary>
        public static IServiceCollection AddAppMetricsGcEventsMetricsCollector(
            this IServiceCollection services,
            Action <MetricsGcEventsCollectorOptions> optionsSetup = null)
        {
            var options = new MetricsGcEventsCollectorOptions();

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

            return(services.AddHostedService <GcEventsCollectorHostedService>());
        }
 public GcEventsCollectorHostedService(IMetrics metrics, MetricsGcEventsCollectorOptions options)
 {
     _metrics = metrics;
     _options = options;
 }