Consume raw data from Metrics

Component: Metrics
NuGet Package NServiceBus.Metrics (3-pre)
Target NServiceBus Version: 7.x
This page targets a pre-release version and is subject to change prior to the final release.

When Performance Counters reporting and Service Control reporting is not enough, it's possible to consume raw metrics data, directly attaching to the public API provided by the package. First, the Metrics themselves need to be enabled. Then, a custom reporter can be attached to send data to any collector e.g. Service Control, Azure Application Insights, etc.

Enabling NServiceBus.Metrics

var metrics = endpointConfiguration.EnableMetrics();

Reporting metrics data

Metrics can be reported in a few different ways.

To any external storage

Custom observers might be registered to access every value reported by probes.

    register: context =>
        foreach (var duration in context.Durations)
                observer: (ref DurationEvent @event) =>
                    Console.WriteLine($"Duration: '{duration.Name}'. Value: '{@event.Duration}'");
        foreach (var signal in context.Signals)
                observer: (ref SignalEvent @event) =>
                    Console.WriteLine($"Signal: '{signal.Name}'. Type: '{@event.MessageType}'");


Last modified