Sentry-python: Sentry not logging Gunicorn timeout errors

Created on 23 Sep 2019  路  4Comments  路  Source: getsentry/sentry-python

We have quite a standard gunicorn setup with the default sync worker with the default 1 thread, running a Python app.

Gunicorn is started with this command line:

gunicorn \
    --workers=16 \
    --timeout=120 \
    -b 127.0.0.1:8082 \
    --paste production.ini \
    2>> api-err.log 1>> api-out.log

The Python Sentry integration is loaded with the following:

import sentry_sdk
from sentry_sdk.integrations.pyramid import PyramidIntegration

sentry_sdk.init(
    dsn="https://[email protected]/123",
    integrations=[PyramidIntegration()],
    release='1.2.3'
)

config = Configurator(settings=settings)
...

The issue is that whenever a Gunicorn worker timeout occurs, it is not logged to Sentry.
The only way we can see that there was a timeout is when we see "[CRITICAL] WORKER TIMEOUT" in api-err.log and the matching error code 499 lines in nginx.log.

It'd be important to log these timeout events to Sentry.

enhancement help wanted

Most helpful comment

Bump on the issue. Similar configuration but with gunicorn + falcon + sentry sdk.

All 4 comments

Could you write a python script that contains the same thing as your gunicorn executable, but calls sentry_sdk.init before running gunicorn? Trying to confirm something

This is the gunicorn executable:

```

!/opt/conda/bin/python

-- coding: utf-8 --

import re
import sys

from gunicorn.app.wsgiapp import run

if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script.pyw?|.exe)?$', '', sys.argv[0])
sys.exit(run())
````

Yes, could you edit it to call sentry_sdk.init() (with your DSN) before it calls run()? I believe this could "fix" the problem already.

Bump on the issue. Similar configuration but with gunicorn + falcon + sentry sdk.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

miracle2k picture miracle2k  路  6Comments

untitaker picture untitaker  路  3Comments

amureki picture amureki  路  6Comments

tonal picture tonal  路  4Comments

steven-murray picture steven-murray  路  3Comments