Console

The App.Metrics.Reporting.Console nuget package writes metrics to the Windows Console via standard output. The default output is plain text using App.Metrics.Formatters.Ascii which can be substituted with any other App Metrics Formatter.

Getting started

To use the console reporter, first install the nuget package:

nuget install App.Metrics.Reporting.Console

Then enable the reporter using Report.ToConsole():

var metrics = new MetricsBuilder()
    .Report.ToConsole()
    .Build();

App Metrics at the moment leaves report scheduling up the the user unless using App.Metrics.AspNetCore. To run all configured reports use the ReportRunner on IMetricsRoot:

await metrics.ReportRunner.RunAllAsync();

Report Scheduling will be added when Microsoft.Extensions.Hosting.Background is released, otherwise there are various other scheduling solutions available for C#.

Configuration

Configuration options are provided as a setup action used with ToConsole().

To configure the console reporters options:

var filter = new MetricsFilter().WhereType(MetricType.Timer);
var metrics = new MetricsBuilder()
    .Report.ToConsole(
        options => {
            options.FlushInterval = TimeSpan.FromSeconds(5);
            options.Filter = filter;
            options.MetricsOutputFormatter = new MetricsJsonOutputFormatter();
        })
    .Build();

Configuration options provided are:

Option Description
MetricsOutputFormatter The formatter used when writing metrics to System.Console.
Filter The filter used to filter metrics just for this reporter.
FlushInterval The delay between flushing metrics to System.Console.