This repository was archived by the owner on Oct 23, 2023. It is now read-only.
This repository was archived by the owner on Oct 23, 2023. It is now read-only.
Exception being send to Sentry even when added to ignore_exception #869
Open
Description
Hello,
I have a Django project using raven 5.27.1 and I setting the the ignore_exception
like so:
RAVEN_CONFIG = {
...
'ignore_exceptions': [myproject.base.exceptions.BackOffException'],
...
}
I also have a celery task that raises that exception:
@shared_task(throws=(BackOffException,))
def my_useful_task():
raise BackOffException
My problem is that raven is not respecting my ignore_exception
config and sending the exception to Sentry anyway. The problem seems to be that the should_capture is being executed twice, I added the following to log to it:
def should_capture(self, exc_info):
exc_type = exc_info[0]
exc_name = '%s.%s' % (exc_type.__module__, exc_type.__name__)
exclusions = self.ignore_exceptions
self.logger.error('hello {} {}'.format(exc_name, exclusions))
And these are logs that I am seeing:
hello myproject.base.exceptions.BackOffException set()
hello myproject.base.exceptions.BackOffException {'myproject.base.exceptions.BackOffException'}
Not capturing exception due to filters: <class 'myproject.base.exceptions.BackOffException'>
Traceback (most recent call last):
File "/code/virtualenv/CURRENT/lib/python3.5/site-packages/celery/app/trace.py", line 240, in trace_task
R = retval = fun(*args, **kwargs)
File "/code/virtualenv/CURRENT/lib/python3.5/site-packages/celery/app/trace.py", line 438, in __protected_call__
return self.run(*args, **kwargs)
File "/code/scp/python/myproject/tasks.py", line 98, in my_useful_task
raise BackOffException
myproject.base.exceptions.BackOffException
pathname=/code/virtualenv/CURRENT/lib/python3.5/site-packages/celery/utils/log.py lineno=282 Task myproject.my_useful_task[145d2141-8fbc-4c9e-bcad-4ce8c3d9b7d9] raised unexpected: BackOffException()
Traceback (most recent call last):
File "/code/virtualenv/CURRENT/lib/python3.5/site-packages/celery/app/trace.py", line 240, in trace_task
R = retval = fun(*args, **kwargs)
File "/code/virtualenv/CURRENT/lib/python3.5/site-packages/celery/app/trace.py", line 438, in __protected_call__
return self.run(*args, **kwargs)
File "/code/scp/python/myproject/tasks.py", line 98, in my_useful_task
raise BackOffException
myproject.base.exceptions.BackOffException
As you can see, should_capture
was called twice, the first time the exclusion list was an empty set. I think this is causing the error to be sent to Sentry anyway