2

NServiceBus.Extensions.Diagnostics 2.0 Released

 2 years ago
source link: https://jimmybogard.com/nservicebus-extensions-diagnostics-2-0-released/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

NServiceBus.Extensions.Diagnostics 2.0 Released

Jimmy Bogard

15 Feb 2022 • 1 min read

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!


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK