---
title: "Event Processors"
description: "Learn more about how you can add your own event processors globally or to the current scope."
url: https://docs.sentry.io/platforms/python/enriching-events/event-processors/
---

# Event Processors | Sentry for Python

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 `before_send` and `before_send_transaction`, there are two key differences:

* Event processors added with either `add_global_event_processor` or `scope.add_event_processor` run in an undetermined order, which means changes to the event may still be made after the event processor runs. `before_send` and `before_send_transaction` are 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).
* While `before_send`, `before_send_transaction`, and processors added with `add_global_event_processor` run globally, regardless of scope, processors added with `scope.add_event_processor` only run on events captured while that scope is active.

Like `before_send` and `before_send_transaction`, event processors are passed two arguments, the event itself and [a `hint` object](https://docs.sentry.io/platforms/python/configuration/filtering.md#using-hints) containing extra metadata.

Event processors added to the global scope will run on every event sent after they've been added.

```python
import sentry_sdk
from sentry_sdk.types import Event, Hint
from sentry_sdk.scope import add_global_event_processor

sentry_sdk.init(
  # ...
)

def event_processor(event, hint):
    event["tags"] = {"foo": "42"}
    return event

global_scope = sentry_sdk.get_global_scope()
global_scope.add_event_processor(event_processor)

# You can do the same thing using add_global_event_processor
add_global_event_processor(event_processor)
```

Event processors added to a local scope using `new_scope` or `isolation_scope` will only apply to events captured inside that scope.

```python
with sentry_sdk.new_scope() as scope:
    scope.add_event_processor(event_processor)

    # The processor applies only inside this scope
    sentry_sdk.capture_message("Test")

# The event processor will NOT apply to this event
sentry_sdk.capture_message("Test");
```
