Skip to content

Instantly share code, notes, and snippets.

@ramonsmits
Created April 4, 2018 14:40
Show Gist options
  • Select an option

  • Save ramonsmits/970c8a29d825b044b40479aaaf8c52cd to your computer and use it in GitHub Desktop.

Select an option

Save ramonsmits/970c8a29d825b044b40479aaaf8c52cd to your computer and use it in GitHub Desktop.
NServiceBus - Add a strack trace to every message send
class AddStackTraceMutator : IMutateOutgoingTransportMessages
{
public Task MutateOutgoing(MutateOutgoingTransportMessageContext context)
{
context.OutgoingHeaders["StackTrace"] = System.Environment.StackTrace;
return Task.CompletedTask;
}
}
endpointConfiguration.RegisterMessageMutator(new AddStackTraceMutator ());
// Via send options
var sendOptions = new SendOptions();
sendOptions.SetHeader("StackTrace", System.Environment.StackTrace);
await context.Send(myMessage, sendOptions).ConfigureAwait(false);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment