Write metrics to the trace log

Component: Metrics
NuGet Package NServiceBus.Metrics (2-pre)
Target NServiceBus Version: 7.x
This page targets a pre-release version and is subject to change prior to the final release.
  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 metrics = endpointConfiguration.EnableMetrics();
metrics.RegisterObservers(
    register: context =>
    {
        foreach (var duration in context.Durations)
        {
            duration.Register(
                observer: (ref DurationEvent @event) =>
                {
                    Trace.WriteLine($"Duration: '{duration.Name}'. Value: '{@event.Duration}'");
                });
        }
        foreach (var signal in context.Signals)
        {
            signal.Register(
                observer: (ref SignalEvent @event) =>
                {
                    Trace.WriteLine($"Signal: '{signal.Name}'");
                });
        }
    });

Related Articles

  • Metrics
    Measuring the performance and health of an endpoint.

Last modified