コード例 #1
0
        /// <summary>
        ///     Add the <see cref="MetricsTextOutputFormatter" /> allowing metrics to optionally be reported as plain text.
        /// </summary>
        /// <param name="metricFormattingBuilder">
        ///     The <see cref="IMetricsOutputFormattingBuilder" /> used to configure formatting
        ///     options.
        /// </param>
        /// <param name="setupAction">The plain text formatting options to use.</param>
        /// <returns>
        ///     An <see cref="IMetricsBuilder" /> that can be used to further configure App Metrics.
        /// </returns>
        public static IMetricsBuilder AsPlainText(
            this IMetricsOutputFormattingBuilder metricFormattingBuilder,
            Action <MetricsTextOptions> setupAction = null)
        {
            if (metricFormattingBuilder == null)
            {
                throw new ArgumentNullException(nameof(metricFormattingBuilder));
            }

            var options = new MetricsTextOptions();

            setupAction?.Invoke(options);

            var formatter = new MetricsTextOutputFormatter();

            return(metricFormattingBuilder.Using(formatter));
        }
コード例 #2
0
 public MyOutputFormatter()
 {
     _options     = new MetricsTextOptions();
     MetricFields = new MetricFields();
 }
コード例 #3
0
 public MyOutputFormatter(MetricsTextOptions options)
 {
     _options     = options ?? throw new ArgumentNullException(nameof(options));
     MetricFields = new MetricFields();
 }