I am using sentry to report errors ocurring in my django app.
Is there a way to disable sentry error reporting when using a command like
python manage.py shell
For ignoring some or all types of exceptions in Sentry you can use
ignore_exceptions
option for RAVEN_CONFIG
in your settings.py
file.
ignore_exceptions
accepts a list of Exception Classes or String Paths.
You can read more about ignoring exceptions in Sentry docs here: https://docs.sentry.io/clients/python/advanced/
To ignore all exceptions, you can pass ['*']
to ignore_exceptions
, but you want to do this only when the django process has been started with the mentioned command in question, which could be known from sys.argv
. So, your desired outcome could be achieved by adding following codes to your django settings.py
file:
import sys
SHOULD_IGNORE_EXCEPTIONS = " ".join(sys.argv).endswith("run python manage.py shell")
RAVEN_CONFIG = {
'dsn': '...',
'ignore_exceptions': ['*'] if SHOULD_IGNORE_EXCEPTIONS else [],
}
There is an undocumented but definetly stable setting for that:
RAVEN_CONFIG = {
'install_sys_hook': False
}
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