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

Attach extra data to exceptions #171

Open
blueyed opened this issue Jul 26, 2017 · 0 comments
Open

Attach extra data to exceptions #171

blueyed opened this issue Jul 26, 2017 · 0 comments

Comments

@blueyed
Copy link
Contributor

blueyed commented Jul 26, 2017

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?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant