NServiceBus.Extensions.Diagnostics 2.0 Released

Last week I pushed out the 2.0 release of NServiceBus.Extensions.Diagnostics package:

And related packages:

The biggest feature change was to allow behaviors to be able to modify the original activity started by accessing an ICurrentActivity from the ContextBag instead of using Activity.Current, which may or may not represent the incoming/outgoing activity. This lets activity enrichment be more precise if you're trying to add tags/baggage to the NServiceBus activity and not something else:

public Task Handle(Message message, IMessageHandlerContext context)
{
    var currentActivity = context.Extensions.Get<ICurrentActivity>();

    currentActivity.Current?.AddBaggage("cart.operation.id", message.Id.ToString());

    // rest of method
}

This can be used anywhere you can get to the context.Extensions, which includes individual handlers as well as cross-cutting behaviors.

Enjoy!