Manage Custom Context

Custom contexts allow you to attach arbitrary data (strings, lists, dictionaries) to an event. You cannot search these, but they are viewable on the issue page:

Custom contexts as viewed on the Additional Data section of an event

To configure additional context:

from sentry_sdk import configure_scope

with configure_scope() as scope:
    scope.set_context("character", {
        "name": "Mighty Fighter",
        "age": 19,
        "attack_type": "melee"

When sending context, be aware of maximum payload size, especially if you want to send the whole application state as extra data. Sentry does not recommend this approach since application state can be very large and easily exceed the 200kB maximum that Sentry has on individual event payloads. When this happens, you’ll receive an HTTP Error 413 Payload Too Large message as the server response or (when you set keepalive: true as a fetch parameter), the request will stay pending forever (for example, in Google Chrome).

Sentry will try its best to accommodate the data you send, but Sentry will trim large context payloads or truncate the payloads entirely.

For more details, see the full documentation on SDK data handling.

Extra Data, Additional Data

If you come across any usages of "extra" (setExtra in code) or "Additional Data" (in the UI), just mentally substitute it for context. Extra is deprecated in favor of context.

You can edit this page on GitHub.