Beispiel #1
0
 internal MetricsReportingBuilder(
     IMetricsBuilder metricsBuilder,
     MetricsFormatterCollection formatters,
     Action <IReportMetrics> reporters)
 {
     Builder     = metricsBuilder ?? throw new ArgumentNullException(nameof(metricsBuilder));
     _formatters = formatters ?? throw new ArgumentNullException(nameof(formatters));
     _reporters  = reporters ?? throw new ArgumentNullException(nameof(reporters));
 }
        public DefaultMetricsResponseWriter(
            IMetricsOutputFormatter fallbackFormatter,
            IReadOnlyCollection <IMetricsOutputFormatter> formatters)
        {
            if (formatters == null)
            {
                throw new ArgumentNullException(nameof(formatters));
            }

            _formatters        = new MetricsFormatterCollection(formatters.ToList());
            _fallbackFormatter = fallbackFormatter;
        }
        public void Can_remove_formatter_by_type()
        {
            // Arrange
            var formatters = new MetricsFormatterCollection();

            formatters.TryAdd(new MetricsJsonOutputFormatter());
            formatters.TryAdd(new MetricsTextOutputFormatter());

            // Act
            formatters.RemoveType <MetricsTextOutputFormatter>();

            // Assert
            formatters.Single().Should().BeOfType(typeof(MetricsJsonOutputFormatter));
        }
        public void Can_get_formatter_by_type()
        {
            // Arrange
            var formatters = new MetricsFormatterCollection();

            formatters.TryAdd(new MetricsJsonOutputFormatter());
            formatters.TryAdd(new MetricsTextOutputFormatter());

            // Act
            var result = formatters.GetType <MetricsTextOutputFormatter>();

            // Assert
            result.Should().BeOfType(typeof(MetricsTextOutputFormatter));
        }
        public void Can_remove_formatter_by_media_type()
        {
            // Arrange
            var formatters = new MetricsFormatterCollection();

            formatters.TryAdd(new MetricsJsonOutputFormatter());
            formatters.TryAdd(new MetricsTextOutputFormatter());
            var mediaType = new MetricsMediaTypeValue("application", "vnd.appmetrics.metrics", "v1", "json");

            // Act
            formatters.RemoveType(mediaType);

            // Assert
            formatters.Single().Should().BeOfType(typeof(MetricsTextOutputFormatter));
        }
        public void Can_get_formatter_by_media_type()
        {
            // Arrange
            var formatters = new MetricsFormatterCollection();

            formatters.TryAdd(new MetricsJsonOutputFormatter());
            formatters.TryAdd(new MetricsTextOutputFormatter());
            var mediaType = new MetricsMediaTypeValue("text", "vnd.appmetrics.metrics", "v1", "plain");

            // Act
            var result = formatters.GetType(mediaType);

            // Assert
            result.Should().BeOfType(typeof(MetricsTextOutputFormatter));
        }
        public void Should_remove_formatter_of_existing_type_when_adding()
        {
            // Arrange
            var formatters        = new MetricsFormatterCollection();
            var existingFormatter = new MetricsJsonOutputFormatter();

            formatters.TryAdd(existingFormatter);
            formatters.TryAdd(new MetricsTextOutputFormatter());

            // Act
            var newFormatter = new MetricsJsonOutputFormatter();

            formatters.TryAdd(newFormatter);

            // Assert
            formatters.Single(f => f.GetType() == typeof(MetricsJsonOutputFormatter)).Should().NotBeSameAs(existingFormatter);
        }
Beispiel #8
0
 public MetricsRoot(
     IMetrics metrics,
     MetricsOptions options,
     MetricsFormatterCollection metricsOutputFormatters,
     EnvFormatterCollection envOutputFormatters,
     IMetricsOutputFormatter defaultMetricsOutputFormatter,
     IEnvOutputFormatter defaultEnvOutputFormatter,
     EnvironmentInfoProvider environmentInfoProvider,
     MetricsReporterCollection reporterCollection,
     IRunMetricsReports reporter)
 {
     Options                       = options ?? throw new ArgumentNullException(nameof(options));
     _metrics                      = metrics ?? throw new ArgumentNullException(nameof(metrics));
     ReportRunner                  = reporter ?? throw new ArgumentNullException(nameof(reporter));
     _environmentInfoProvider      = new EnvironmentInfoProvider();
     Reporters                     = reporterCollection ?? new MetricsReporterCollection();
     OutputMetricsFormatters       = metricsOutputFormatters ?? new MetricsFormatterCollection();
     OutputEnvFormatters           = envOutputFormatters ?? new EnvFormatterCollection();
     DefaultOutputMetricsFormatter = defaultMetricsOutputFormatter;
     DefaultOutputEnvFormatter     = defaultEnvOutputFormatter;
     _environmentInfoProvider      = environmentInfoProvider;
 }
 public MetricsEndpointsOptionsSetup(IReadOnlyCollection <IEnvOutputFormatter> envFormatters, IReadOnlyCollection <IMetricsOutputFormatter> metricsFormatters)
 {
     _envFormatters     = new EnvFormatterCollection(envFormatters.ToList());
     _metricsFormatters = new MetricsFormatterCollection(metricsFormatters.ToList());
 }