Diagnostics and Instrumentation Packages for MongoDB and NServiceBus Published
As part of the end-to-end diagnostics and tracing blog series, I had an end goal of eventually publishing out NuGet packages for diagnostics (Activity and DiagnosticSource). I'm happy to announce that I've released 4 packages to NuGet:
- NServiceBus.Extensions.Diagnostics
- NServiceBus.Extensions.Diagnostics.OpenTelemetry
- MongoDB.Driver.Core.Extensions.DiagnosticSources
- MongoDB.Driver.Core.Extensions.OpenTelemetry
These packages add:
- Activity and DiagnosticsSource support
- OpenTelemetry adapters
- W3C Trace Context and Correlation Context support for NServiceBus
With the diagnostics packages, you can write your own DiagnosticListener
s to subscribe to diagnostics Activity events. The OpenTelemetry packages listen to these Activity events and adapt them to OpenTelemetry spans. The various existing exporters can output these spans to Zipkin, Jaeger, Application Insights, and many other observability tools.
I've updated the ReadMe's for each repo to include instructions for how to use:
With these packages, you can easily configure OpenTelemetry to include MongoDB and NServiceBus support:
services.AddOpenTelemetry(builder =>
builder
.UseZipkin(o =>
{
o.Endpoint = new Uri("http://localhost:9411/api/v2/spans");
o.ServiceName = EndpointName;
})
.AddNServiceBusAdapter(opt => opt.CaptureMessageBody = true)
.AddMongoDBAdapter(opt => opt.CaptureCommandText = true)
.AddRequestAdapter()
.AddDependencyAdapter(configureSqlAdapterOptions: opt => opt.CaptureTextCommandContent = true);
);
Enjoy!