TimmyGilissen / NServiceBus.Extensions.Diagnostics

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

NServiceBus.Extensions.Diagnostics

CI NuGet NuGet MyGet (dev)

Usage

The NServiceBus.Extensions.Diagnostics package extends NServiceBus to expose telemetry information via System.Diagnostics.

To use NServiceBus.Extensions.Diagnostics, simply reference the package. The DiagnosticsFeature is enabled by default.

The Diagnostics package exposes four different events from behaviors via Diagnostics:

  • IIncomingPhysicalMessageContext
  • IIncomingLogicalMessageContext
  • IOutgoingPhysicalMessageContext
  • IOutgoingLogicalMessageContext
  • IInvokeHandlerContext

The Physical message variants include full Activity support. All diagnostics events pass through the corresponding context object as its event argument.

This package supports NServiceBus version 7.0 and above.

W3C traceparent and Correlation-Context support

The Diagnostics package also provides support for both the W3C Trace Context recommendation and W3C Correlation Context June 2020 draft.

The Trace Context supports propagates the traceparent and tracecontext headers into outgoing messages, and populates Activity parent ID based on incoming messages.

The Correlation Context support consumes incoming headers into Activity.Baggage, and propagates Activity.Baggage into outgoing messages.

If you would like to add additional correlation context, inside your handler you can add additional baggage:

Activity.Current.AddBaggage("mykey", "myvalue");

Correlation context can then flow out to tracing and observability tools. Common usage for correlation context are user IDs, session IDs, conversation IDs, and anything you might want to search traces to triangulate specific traces.

About

License:Apache License 2.0


Languages

Language:C# 94.6%Language:PowerShell 5.4%