/// <summary>
        ///     Add the <see cref="MetricsPrometheusFormatterBuilder" /> allowing metrics to optionally be formatted in Prometheus plain text format
        /// </summary>
        /// <param name="metricFormattingBuilder">s
        ///     The <see cref="IMetricsOutputFormattingBuilder" /> used to configure Prometheus formatting
        ///     options.
        /// </param>
        /// <param name="options">The Prometheus formatting options to use.</param>
        /// <returns>
        ///     An <see cref="IMetricsBuilder" /> that can be used to further configure App Metrics.
        /// </returns>
        public static IMetricsBuilder AsPrometheusPlainText(
            this IMetricsOutputFormattingBuilder metricFormattingBuilder,
            MetricsPrometheusOptions options)
        {
            if (metricFormattingBuilder == null)
            {
                throw new ArgumentNullException(nameof(metricFormattingBuilder));
            }

            var formatter = new MetricsPrometheusTextOutputFormatter(options);

            return(metricFormattingBuilder.Using(formatter, false));
        }
Пример #2
0
            public void Configure(MetricEndpointsOptions options)
            {
                var prometheusOptions = new MetricsPrometheusOptions();

                options.EnvironmentInfoEndpointEnabled = true;
                options.EnvInfoEndpointOutputFormatter = new EnvInfoJsonOutputFormatter();

                options.MetricsEndpointEnabled         = true;
                options.MetricsEndpointOutputFormatter =
                    new MetricsPrometheusProtobufOutputFormatter(prometheusOptions);

                options.MetricsTextEndpointEnabled         = true;
                options.MetricsTextEndpointOutputFormatter =
                    new MetricsPrometheusTextOutputFormatter(prometheusOptions);
            }
        /// <summary>
        ///     Add the <see cref="MetricsPrometheusFormatterBuilder" /> allowing metrics to optionally be formatted in Prometheus plain text format
        /// </summary>
        /// <param name="metricFormattingBuilder">s
        ///     The <see cref="IMetricsOutputFormattingBuilder" /> used to configure Prometheus formatting
        ///     options.
        /// </param>
        /// <param name="setupAction">The Prometheus formatting options to use.</param>
        /// <returns>
        ///     An <see cref="IMetricsBuilder" /> that can be used to further configure App Metrics.
        /// </returns>
        public static IMetricsBuilder AsPrometheusPlainText(
            this IMetricsOutputFormattingBuilder metricFormattingBuilder,
            Action <MetricsPrometheusOptions> setupAction)
        {
            if (metricFormattingBuilder == null)
            {
                throw new ArgumentNullException(nameof(metricFormattingBuilder));
            }

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

            var options = new MetricsPrometheusOptions();

            setupAction.Invoke(options);

            var formatter = new MetricsPrometheusTextOutputFormatter(options);

            return(metricFormattingBuilder.Using(formatter, false));
        }