Esempio n. 1
0
        public async Task Can_flush_metrics_to_console_with_defaults()
        {
            // Arrange
            var reporter = new ConsoleMetricsReporter();
            var snapshot = new MetricsDataValueSource(DateTime.Now, Enumerable.Empty <MetricsContextValueSource>());

            // Act
            var result = await reporter.FlushAsync(snapshot, CancellationToken.None);

            // Assert
            result.Should().BeTrue();
        }
        /// <summary>
        ///     Add the <see cref="ConsoleMetricsReporter" /> allowing metrics to be reported to console.
        /// </summary>
        /// <param name="reportingBuilder">
        ///     The <see cref="IMetricsReportingBuilder" /> used to configure metrics reporters.
        /// </param>
        /// <param name="options">The console reporting options to use.</param>
        /// <returns>
        ///     An <see cref="IMetricsBuilder" /> that can be used to further configure App Metrics.
        /// </returns>
        public static IMetricsBuilder ToConsole(
            this IMetricsReportingBuilder reportingBuilder,
            MetricsReportingConsoleOptions options)
        {
            if (reportingBuilder == null)
            {
                throw new ArgumentNullException(nameof(reportingBuilder));
            }

            var provider = new ConsoleMetricsReporter(options);

            return(reportingBuilder.Using(provider));
        }
        /// <summary>
        ///     Add the <see cref="ConsoleMetricsReporter" /> allowing metrics to be reported to console.
        /// </summary>
        /// <param name="reportingBuilder">
        ///     The <see cref="IMetricsReportingBuilder" /> used to configure metrics reporters.
        /// </param>
        /// <param name="setupAction">The console reporting options to use.</param>
        /// <returns>
        ///     An <see cref="IMetricsBuilder" /> that can be used to further configure App Metrics.
        /// </returns>
        public static IMetricsBuilder ToConsole(
            this IMetricsReportingBuilder reportingBuilder,
            Action <MetricsReportingConsoleOptions> setupAction)
        {
            if (reportingBuilder == null)
            {
                throw new ArgumentNullException(nameof(reportingBuilder));
            }

            var options = new MetricsReportingConsoleOptions();

            setupAction?.Invoke(options);

            var provider = new ConsoleMetricsReporter(options);

            return(reportingBuilder.Using(provider));
        }
Esempio n. 4
0
        public async Task Can_flush_metrics_to_console_with_options()
        {
            // Arrange
            var filter    = new MetricsFilter().WhereType(MetricType.Apdex);
            var formatter = new TestMetricsFormatter();
            var interval  = TimeSpan.FromDays(1);
            var options   = new MetricsReportingConsoleOptions
            {
                Filter = filter,
                MetricsOutputFormatter = formatter,
                FlushInterval          = interval
            };
            var reporter = new ConsoleMetricsReporter(options);
            var snapshot = new MetricsDataValueSource(DateTime.Now, Enumerable.Empty <MetricsContextValueSource>());

            // Act
            var result = await reporter.FlushAsync(snapshot, CancellationToken.None);

            // Assert
            result.Should().BeTrue();
        }