Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(.NET): Added EventProcessor #7599

Merged
merged 3 commits into from
Aug 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions src/platform-includes/enriching-events/event-processors/dotnet.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
You can create your own event processors by implementing the `ISentryEventProcessor` interfact. You can also create custom processors for transactions by implementing the `ISentryTransactionProcessor`.

```csharp
using Sentry;
using Sentry.Extensibility;

public class CustomEventProcessor : ISentryEventProcessor
{
public SentryEvent? Process(SentryEvent @event)
{
// Add anything to the event here
// returning `null` will drop the event
return @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.

```csharp
options.AddEventProcessor(new CustomEventProcessor());
```

If `AddEventProcessor` has been added to the scope, it'll apply to both the current and the following scopes:

```csharp
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.

```csharp
SentrySdk.WithScope(scope => scope.AddEventProcessor(new CustomEventProcessor()));
```
1 change: 0 additions & 1 deletion src/platforms/common/enriching-events/event-processors.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ notSupported:
- android
- apple
- dart
- dotnet
- elixir
- flutter
- go
Expand Down
Loading