Raise warning when using async Sentry transport.

main
Vincent Driessen 11 years ago
parent 2314b62d8c
commit 6644872273

@ -1,7 +1,7 @@
### 0.4.6 ### 0.4.6
(not released yet) (not released yet)
- ... - Fix where Sentry logging did not reliably work in the worker process.
### 0.4.5 ### 0.4.5

@ -1,12 +1,24 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
from __future__ import (absolute_import, division, print_function, from __future__ import (absolute_import, division, print_function,
unicode_literals) unicode_literals)
import warnings
def register_sentry(client, worker): def register_sentry(client, worker):
"""Given a Raven client and an RQ worker, registers exception handlers """Given a Raven client and an RQ worker, registers exception handlers
with the worker so exceptions are logged to Sentry. with the worker so exceptions are logged to Sentry.
""" """
def uses_supported_transport(url):
supported_transports = set(['sync+', 'requests+'])
return any(url.startswith(prefix) for prefix in supported_transports)
if not any(uses_supported_transport(s) for s in client.servers):
msg = ('Sentry error delivery is known to be unreliable when not '
'delivered synchronously from RQ workers. You are encouraged '
'to change your DSN to use the sync+ or requests+ transport '
'prefix.')
warnings.warn(msg, UserWarning, stacklevel=2)
def send_to_sentry(job, *exc_info): def send_to_sentry(job, *exc_info):
client.captureException( client.captureException(
exc_info=exc_info, exc_info=exc_info,

Loading…
Cancel
Save