Django / Sentry Integration - No events Reported

I can not for the life of me get 500’s in my django app to create events on sentry.

I’m following the new sdk django integration instructions here. I’ve created a view that triggers the divide by zero error. In production I load the url and get a 500 for sure. I have another 500 from a different error of mine I’ve tried as well.

These show up in my logs, but they do not show up in sentry.

When I run the python-based Verifying Your Setup command in the django command line shell:

sentry_sdk.capture_exception(Exception("This is an example of an error message."))

it does show up in sentry. So I know that my settings are importing the correct dsn.

I had thought my issue might be related to this question, but the answer in this question makes not sense to me.

I really want sentry to work, I’ve used it on a client project and I don’t know what the is wrong with it. I’m frustrated with what should be a simple configuration of this tool.

Here is my logging definition from settings.py:

MIN_LOGGING_LEVEL = 'ERROR'
MIN_DJANGO_LEVEL = 'ERROR'

LOGGING = {
'version': 1,
'disable_existing_loggers': False,  # keep Django's default loggers
'formatters': {
    'verbose': {
        'format': '%(levelname)s %(asctime)s %(module)s %(process)d %(thread)d %(message)s'
    },
    'simple': {
        'format': '%(levelname)s %(message)s'
    },
    'timestampthread': {
        'format': "%(asctime)s [%(threadName)-12.12s] [%(levelname)-5.5s] [%(name)-20.20s]  %(message)s",
    },
},
'handlers': {
    'logfile': {
        'level': MIN_LOGGING_LEVEL,  # this level or higher goes to the log file
        'class': 'logging.handlers.RotatingFileHandler',
        'filename': LOG_FILE_PATH,
        'maxBytes': 100 * 10 ** 6,  # will 50 MB do?
        'backupCount': 3,  # keep this many extra historical files
        'formatter': 'timestampthread'
    },
    'console': {
        'level': MIN_LOGGING_LEVEL,  # this level or higher goes to the console
        'class': 'logging.StreamHandler',
    },
},
'loggers': {
    'django': {  # configure all of Django's loggers
        'handlers': ['logfile', 'console'],
        'level': MIN_DJANGO_LEVEL,  # this level or higher goes to the console
        'propagate': False,  # don't propagate further, to avoid duplication
    },
    # root configuration – for all of our own apps
    # (feel free to do separate treatment for e.g. brokenapp vs. sth else)
    '': {
        'handlers': ['logfile', 'console'],
        'level': MIN_LOGGING_LEVEL,  # this level or higher goes to the console,
    },
},

}

Hi, could you post the version of Django you use and which WSGI server you use?

Hey there, I’m running Django 2.5 and uWSGI 2.0.18.

Could you initialize the SDK with init(debug=True)? This should print a lot of information to stdout/err that might indicate internal errors.

were you able to get this to work?? i’m in the exact same situation. The python-based error shows up, but I can’t get the 500 error from /sentry-debug/ to show up. I’d appreciate any help anyone can provide before I’m forced to ditch Sentry for something else.

1 Like

Same problem here.

My on-prem sentry works out of the box with other languages and frameworks.

On django with the latest sdk I get the following messages after a GET on /sentry-debug/:

DEBUG: Sending event, type:null level:error event_id:94377118d84b40be8e6d48943227588c project:2 host:xxx.xxxxxx.xyz
DEBUG:sentry_sdk.errors:Sending event, type:null level:error event_id:94377118d84b40be8e6d48943227588c project:2 host:xxx.xxxxxx.xyz
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): xxx.xxxxxx.xyz:443

But Sentry never receives anything.