Write metrics to the trace log

Component: Metrics
NuGet Package NServiceBus.Metrics (1.x)
Target NServiceBus Version: 6.x
  1. Run the solution in the Visual Studio debugger. A console application will start
  2. Press the 'enter' key to send a message
  3. Check the debug output window for metric information being written to the trace log

Send metric data to Trace Log

var metricsOptions = endpointConfiguration.EnableMetrics();
metricsOptions.RegisterObservers(context =>
{
    foreach (var duration in context.Durations)
    {
        duration.Register(durationLength =>
        {
            Trace.WriteLine($"Duration '{duration.Name}' value observed: '{durationLength}'");
        });
    }
    foreach (var signal in context.Signals)
    {
        signal.Register(() =>
        {
            Trace.WriteLine($"'{signal.Name}' occurred.");
        });
    }
});

Related Articles

  • Metrics
    Measuring the performance and health of an endpoint.

Last modified