Skip to content
etishor edited this page Sep 27, 2014 · 24 revisions

The Metrics.NET library provides a way of instrumenting applications with custom metrics (timers, histograms, counters etc) that can be reported in various ways and can provide insights on what is happening inside a running application.

###Installation

The library and the adapters are available on NuGet:

    Install-Package Metrics.NET
    Install-Package Nancy.Metrics
    Install-Package Owin.Metrics

###Configuration

using Metrics;

Metric.Config
    .WithHttpEndpoint("http://localhost:1234/")
    .WithAllCounters()
    .WithReporting(config => config
        .WithConsoleReport(TimeSpan.FromSeconds(30))
        .WithCSVReports(@"c:\temp\reports\", TimeSpan.FromSeconds(10))
        .WithTextFileReport(@"C:\temp\reports\metrics.txt", TimeSpan.FromSeconds(10))
    );

###App.Config settings

<!-- Completely disable all metrics -->
<add key="Metrics.CompetelyDisableMetrics" value="true"/>

<!-- Equivalent of calling Metric.Config.WithHttpEndpoint("http://localhost:1234/") -->
<add key="Metrics.HttpListener.HttpUriPrefix" value="http://localhost:1234/"/>

<!-- Equivalent of calling 
Metric.Config.WithReporting(config => 
config.WithCSVReports(@"..\MetricsCSV\", TimeSpan.FromSeconds(10))
-->
<add key="Metrics.CSV.Path" value="..\MetricsCSV\"/>
<add key="Metrics.CSV.Interval.Seconds" value="10"/>

###Documentation

The sample folder in the repository contains some usage samples.