You can enrich events with additional data by adding your own event processors, either on the scope level or globally. Though event processors are similar to
BeforeSendTransaction, there are two key differences:
BeforeSendTransactionare guaranteed to be run last, after all other event processors, (which means they get the final version of the event right before it's sent, hence the name). Event processors added with either of the methods below run in an undetermined order, which means changes to the event may still be made after the event processor runs.
BeforeSendTransaction, and processors added with
Sentry.addGlobalEventProcessorrun globally, regardless of scope, processors added with
Scope.addEventProcessoronly run on events captured while that scope is active.
BeforeSendTransaction, event processors are passed two arguments, the event itself and a
hint object containing extra metadata.
You can create your own event processors by implementing the
ISentryEventProcessor interface. You can also create custom processors for transactions by implementing the
public class CustomEventProcessor : ISentryEventProcessor
public SentryEvent? Process(SentryEvent @event)
// Add anything to the event here
// returning `null` will drop the event
Processors run on every event sent once they've been added. While there are multiple ways of doing this, adding processors to the options ensures that they run with every event after initialization.
AddEventProcessor has been added to the scope, it'll apply to both the current and the following scopes:
SentrySdk.ConfigureScope(scope => scope.AddEventProcessor(new CustomEventProcessor()));
But if an event processor has only been added to a local scope using
withScope, it'll only apply to events captured inside that scope.
SentrySdk.WithScope(scope => scope.AddEventProcessor(new CustomEventProcessor()));