Пример #1
0
        public static void AddMetricsActuator(this IServiceCollection services, IConfiguration config)
        {
            if (services == null)
            {
                throw new ArgumentNullException(nameof(services));
            }

            if (config == null)
            {
                throw new ArgumentNullException(nameof(config));
            }

            services.TryAddSingleton <IDiagnosticsManager, DiagnosticsManager>();
            services.TryAddEnumerable(ServiceDescriptor.Singleton <IHostedService, DiagnosticServices>());

            services.TryAddEnumerable(ServiceDescriptor.Singleton <IManagementOptions>(new ActuatorManagementOptions(config)));
            var options = new MetricsEndpointOptions(config);

            services.TryAddSingleton <IMetricsOptions>(options);
            services.RegisterEndpointOptions(options);
            services.TryAddEnumerable(ServiceDescriptor.Singleton <IDiagnosticObserver, AspNetCoreHostingObserver>());
            services.TryAddEnumerable(ServiceDescriptor.Singleton <MetricExporter, SteeltoeExporter>());
            services.AddOpenTelemetry();

            services.TryAddEnumerable(ServiceDescriptor.Singleton <EventListener, EventCounterListener>());
            services.TryAddEnumerable(ServiceDescriptor.Singleton <EventListener, GCEventsListener>());
            services.TryAddEnumerable(ServiceDescriptor.Singleton <EventListener, ThreadpoolEventsListener>());

            services.TryAddSingleton((provider) => provider.GetServices <MetricExporter>().OfType <SteeltoeExporter>().SingleOrDefault());
            services.TryAddSingleton <MetricsEndpoint>();
        }
Пример #2
0
        public static void AddPrometheusActuator(this IServiceCollection services, IConfiguration config = null)
        {
            if (services == null)
            {
                throw new ArgumentNullException(nameof(services));
            }

            config ??= services.BuildServiceProvider().GetService <IConfiguration>();
            if (config == null)
            {
                throw new ArgumentNullException(nameof(config));
            }

            services.TryAddSingleton <IDiagnosticsManager, DiagnosticsManager>();
            services.TryAddEnumerable(ServiceDescriptor.Singleton <IHostedService, DiagnosticServices>());

            services.TryAddEnumerable(ServiceDescriptor.Singleton <IManagementOptions>(new ActuatorManagementOptions(config)));

            var metricsEndpointOptions = new MetricsEndpointOptions(config);

            services.TryAddSingleton <IMetricsEndpointOptions>(metricsEndpointOptions);

            var observerOptions = new MetricsObserverOptions(config);

            services.TryAddSingleton <IMetricsObserverOptions>(observerOptions);

            services.AddPrometheusActuatorServices(config);

            AddMetricsObservers(services, observerOptions);
            services.TryAddEnumerable(ServiceDescriptor.Singleton <MetricExporter, PrometheusExporter>());
            services.AddOpenTelemetry();
            services.TryAddSingleton((provider) => provider.GetServices <MetricExporter>().OfType <PrometheusExporter>().SingleOrDefault());
            services.AddActuatorEndpointMapping <PrometheusScraperEndpoint>();
        }
Пример #3
0
        public static void AddPrometheusActuator(this IServiceCollection services, IConfiguration config)
        {
            if (services == null)
            {
                throw new ArgumentNullException(nameof(services));
            }

            if (config == null)
            {
                throw new ArgumentNullException(nameof(config));
            }

            services.TryAddSingleton <IDiagnosticsManager, DiagnosticsManager>();
            services.TryAddEnumerable(ServiceDescriptor.Singleton <IHostedService, DiagnosticServices>());
            services.TryAddEnumerable(ServiceDescriptor.Singleton <IPolledDiagnosticSource, CLRRuntimeSource>());

            services.TryAddEnumerable(ServiceDescriptor.Singleton <IManagementOptions>(new ActuatorManagementOptions(config)));

            var metricsOptions = new MetricsEndpointOptions(config);

            services.TryAddSingleton <IMetricsOptions>(metricsOptions);

            var options = new PrometheusEndpointOptions(config);

            services.TryAddSingleton <IPrometheusOptions>(options);
            services.RegisterEndpointOptions(options);
            services.TryAddEnumerable(ServiceDescriptor.Singleton <IDiagnosticObserver, AspNetCoreHostingObserver>());
            services.TryAddEnumerable(ServiceDescriptor.Singleton <IDiagnosticObserver, CLRRuntimeObserver>());

            services.TryAddEnumerable(ServiceDescriptor.Singleton <MetricExporter, PrometheusExporter>());
            services.AddOpenTelemetry();

            services.TryAddSingleton((provider) => provider.GetServices <MetricExporter>().OfType <PrometheusExporter>().SingleOrDefault());
            services.TryAddSingleton <PrometheusScraperEndpoint>();
        }
Пример #4
0
        public static void AddMetricsActuator(this IServiceCollection services, IConfiguration config)
        {
            if (services == null)
            {
                throw new ArgumentNullException(nameof(services));
            }

            if (config == null)
            {
                throw new ArgumentNullException(nameof(config));
            }

            services.TryAddSingleton <IDiagnosticsManager, DiagnosticsManager>();
            services.TryAddEnumerable(ServiceDescriptor.Singleton <IHostedService, DiagnosticServices>());
            services.TryAddEnumerable(ServiceDescriptor.Singleton <IPolledDiagnosticSource, CLRRuntimeSource>());

            services.TryAddEnumerable(ServiceDescriptor.Singleton <IManagementOptions>(new ActuatorManagementOptions(config)));
            var options = new MetricsEndpointOptions(config);

            services.TryAddSingleton <IMetricsOptions>(options);
            services.RegisterEndpointOptions(options);
            services.TryAddEnumerable(ServiceDescriptor.Singleton <IDiagnosticObserver, AspNetCoreHostingObserver>());
            services.TryAddEnumerable(ServiceDescriptor.Singleton <IDiagnosticObserver, CLRRuntimeObserver>());

            services.TryAddSingleton <IStats, OpenCensusStats>();
            services.TryAddSingleton <ITags, OpenCensusTags>();

            services.TryAddSingleton <MetricsEndpoint>();
        }