The App.Metrics.Reporting.Socket nuget package reports metrics through a socket. The reporter has no default output formatter, so one of the available formatters must be provided.

Getting started

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

nuget install App.Metrics.Reporting.Socket

Then install output formatter package of your choice.
For example, to report metrics into Telegraf the InfluxDB package is required:

nuget install App.Metrics.Formatters.InfluxDB


Socket reporter is transport layer to send data via sockets. Socket reporter supports TCP and UDP protocols for both Windows and Unix systems and Unix Domain Sockets for Unix. Reporter is unspecific to formatting protocols, so it can be used with any application that can receive data via sockets.

The reporter was tested with Telegraf. Plugin socket_listener was used to receive metrics.

To send metrics over TCP protocol:

var metrics = new MetricsBuilder()
    .Report.OverTcp("localhost", 8094)

To send metrics over UDP protocol:

var metrics = new MetricsBuilder()
    .Report.OverUdp("", 8094)

To send metrics over Unix Domain Sockets:

var metrics = new MetricsBuilder()


The reporter can be configured through an options object passed to the setup action. There are several reporter-specific and common options.

var formatter = new MetricsInfluxDbLineProtocolOutputFormatter();

var metrics = new MetricsBuilder()
        options => {
            options.SocketSettings.Address = "localhost";
            options.SocketSettings.Port = 8094;

            options.Filter = new MetricsFilter().WhereType(MetricType.Timer);
            options.FlushInterval = TimeSpan.FromSeconds(12);
            options.MetricsOutputFormatter = formatter;
            options.SocketPolicy = new SocketPolicy();

Reporter-specific options are:

SocketSettings.Address SocketSettings.Port
Address of a socket endpoint
(DNS name or IP address)
Port of a socket endpoint
OverUds ”//path/to/socket/file”
(Works only on Unix)
The port must be 0

Common options are:

Option Description
MetricsOutputFormatter The formatter used for format metrics into a string which will be sent over sockets layer.
Filter The filter used to filter metrics.
FlushInterval The delay between each report attempt.
SocketPolicy.FailuresBeforeBackoff The number of failures before backing-off when failing to report metrics to a socket.
SocketPolicy.BackoffPeriod The TimeSpan to back-off when failing to report metrics to a socket.
SocketPolicy.Timeout The timeout duration when attempting to report metrics to a socket.