I'd like sentry/raven to ignore all exceptions from a certain function or django module, but looking into the docs and the code, I only saw an option to ignore a custom exception by adding an extra attribute to it. Is there a way to ignore exceptions by function name or module name? Thanks!
Reading through the source of raven I saw that if you'd like to ignore a certain exceptions you can add them to IGNORE_EXCEPTIONS
like this:
RAVEN_CONFIG = {
'dsn': '...',
'IGNORE_EXCEPTIONS': ['exceptions.ZeroDivisionError', 'some.other.module.CustomException'],
...
}
As for exclusion of certain modules/files the best way would probably be to write your own client and decide whether or not to send a message to sentry. It think you should override the send
method since it has all the data in more accessible form.
You could do it like this:
from raven.contrib.django.client import DjangoClient
class MyClient(DjangoClient):
def send(self, **kwargs):
'''
check if culprit (event name) should be skipped
'''
if kwargs.get('culprit', '').startswith('my.module.to.skip'):
self.logger.info('Skipping entry')
else:
return super(MyClient, self).send(**kwargs)
and then set your custom client in settings.py
:
SENTRY_CLIENT = 'path.to.module.MyClient'
If you want to implement more sophisticated rules for ignoring you should probably check what you can do with the given data (kwargs).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With