Getting Started
Architecture
NServiceBus
Transports
Persistence
ServiceInsight
ServicePulse
ServiceControl
Monitoring
Samples

OpenTelemetry

Component: NServiceBus
NuGet Package: NServiceBus (9.x)

NServiceBus version 8 and above supports OpenTelemetry through traces, metrics, and logging.

Enable OpenTelemetry instrumentation in NServiceBus:

endpointConfiguration.EnableOpenTelemetry();

With OpenTelemetry instrumentation enabled, tracing, metrics, and logging can be individually configured via the OpenTelemetry API itself.

Traces

NServiceBus endpoints generate OpenTelemetry traces for incoming and outgoing messages. To capture trace information, add the NServiceBus.Core activity source to the OpenTelemetry configuration:

var tracingProviderBuilder = Sdk.CreateTracerProviderBuilder()
    .AddSource("NServiceBus.Core")
    // ... Add other trace sources
    // ... Add exporters
    .Build();

See the OpenTelemetry samples for instructions on how to send trace information to different tools.

Meters

NServiceBus endpoints can be configured to expose metrics related to message processing. To capture meter information, add the NServiceBus.Core meter source to the OpenTelemetry configuration:

var meterProviderProvider = Sdk.CreateMeterProviderBuilder()
    .AddMeter("NServiceBus.Core")
    // ... Add other meters
    // ... Add exporters
    .Build();

See the OpenTelemetry samples for instructions on how to send metric information to different tools.

Logging

NServiceBus supports logging out of the box. To collect OpenTelemetry-compatible logging in NServiceBus endpoints, it's possible to configure the endpoint to connect traces and logging when using Microsoft.Extensions.Logging package. See the Connecting OpenTelemetry traces and logs sample for more details.

Samples