AI agents: use the documentation index at llms.txt to locate machine-readable pages. This section is indexed by https://docs.particular.net/samples/llms.txt. The markdown version of this page is served as plain text. An MCP server at /mcp serves the same content via the search_docs and read_doc tools; it is read-only and needs no credentials. Markdown versions of documentation pages are available by appending .md to the page URL. Directory URLs use index.md. They are served as text/plain because some retrieval backends reject text/markdown.

Write metrics to the trace log

Component:
Metrics
NuGet Package:
NServiceBus.Metrics 6.x
Target Version:
NServiceBus 10.x

This sample demonstrates how to write metrics information to the trace log.

There are many ways to look at the trace log. One way is to use the DbgView utility provided by Sysinternals.

DbgView by Sysinternals

Running the sample

  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 Visual Studio debug output window for metrics information being written to the trace log.

Sending metrics 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}' ({@event.MessageType})");
                });
        }

        foreach (var signal in context.Signals)
        {
            signal.Register(
                observer: (ref SignalEvent @event) =>
                {
                    Trace.WriteLine($"Signal: '{signal.Name}' ({@event.MessageType})");
                });
        }
    });

Related Articles

  • Metrics
    Monitor NServiceBus endpoint performance with the Metrics plugin and report data to ServiceControl and visualize in ServicePulse.