Skip to content
This repository was archived by the owner on Jun 11, 2018. It is now read-only.
This repository was archived by the owner on Jun 11, 2018. It is now read-only.

Attach extra data to exceptions #171

Description

@blueyed

It is possible to provide extra information when logging:

logger.error(e, exc_info=True, extra={'key': value})

But I could not find a documented way to do so with exceptions?

It seems to work through a custom capture method (via settings.OPBEAT['CLIENT']):

class OpbeatDjangoClient(opbeat.contrib.django.DjangoClient):
    def capture(self, event_type, request=None, **kwargs):
        kwargs.setdefault(
            'extra', {})['some_setting'] = settings.SOME_SETTING

        if event_type == 'Exception':
            if 'exc_info' in kwargs:
                exc_value = kwargs['exc_info'][1]
                if hasattr(exc_value, 'opbeat_extra'):
                    for k, v in exc_value.opbeat_extra.items():
                        kwargs['extra'][k] = v
        return super().capture(event_type, request, **kwargs)

Would this be something to handle in a generic way via
opbeat.events.Exception.capture?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions