Search code examples
pythondjangosentry

Sentry sdk timeout setting


I have a django app and I was using raven to send events to sentry:

settings.py

RAVEN_CONFIG = {
   'dsn': '***',
   'timeout': 10,
   'transport': 'raven.transport.requests.RequestsHTTPTransport'
}

Now, as I'm switching to newly released sentry-sdk, how do I set timeout? Can't find it neither in docs nor in sentry-sdk code.

import sentry_sdk
from sentry_sdk.integrations.django import DjangoIntegration
sentry_sdk.init(
   dsn="***",
   integrations=[DjangoIntegration()],
   timeout=10
)

Solution

  • Write a custom transport like this:

    import sentry_sdk
    from sentry_sdk.transport import HttpTransport
    
    class NewHttpTransport(HttpTransport):
        def _get_pool_options(self, *a, **kw):
            rv = HttpTransport._get_pool_options(self, *a, **kw)
            rv['timeout'] = 3
            return rv
    
    sentry_sdk.init(transport=NewHttpTransport)