Following the Sentry Django guide I've setup my project and deployed it.
So I configure RAVEN_CONFIG with the SENTRY_DSN value and release values, and include raven.contrib.django.raven_compat in my INSTALLED_APPS.
I've confirmed that with this configuration the following command will properly generate a message in sentry.
python manage.py raven test
However, I've created the following django view to raise an exception as an alternative way to confirm that sentry is working, and when I hit this view, I get a 500 response, but nothing shows up in sentry.
app1/views.py
def error(request):
x = 1/0 # error for sentry testing
My expectation is that any exception (including 500 errors) that occurs in django will be sent to sentry without the need to use logging.
Is my understanding of the raven sentry configuration wrong? Or, do I need to configure something else?
I am using the LOGGING setting of django, but at the moment I don't care if these messages 'error' or otherwise are sent to sentry. My main goal at the moment is to catch and send any exception that occurs to sentry.
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'formatters': {
'standard': {
'format': '{asctime} [{levelname:5}] ({name}) {funcName}: {message}',
'style': '{',
}
},
'handlers': {
'console': {
'class': 'logging.StreamHandler',
'formatter': 'standard',
},
},
'loggers': {
'django': {
'handlers': ['console'],
'level': DJANGO_CORE_LOG_LEVEL, # Change to DEBUG to see db queries
},
'app1': {
'handlers': ['console'],
'level': DJANGO_LOG_LEVEL,
'propagate': True,
},
'app2': {
'handlers': ['console'],
'level': DJANGO_LOG_LEVEL,
'propagate': True,
}
},
}
UPDATE
I've managed to get the app1.views.error view to report an error to sentry when using runserver locally, but after updating the configuration and deploying it's still not working when deployed. (manage raven test does)
From the sentry docs
}
Link to doc: https://docs.sentry.io/clients/python/integrations/django/
EDIT: From the comment
if you don't want to do this manually and want sentry logging to occur anytime an exception block is triggered anywhere in your project, use the logging based solution above.