我使用python-raven作为我的哨兵客户端。不幸的是,当我的服务器上出现错误500(由乌鸦抓住)时,我的请求超时:
E 17:05:57.743 2015-05-13 500 0 B 59.99s /mobile_backend/device/2EBE5887-03EA-458A-B4C4-E57253966231/
137.194.58.229 - - [13/May/2015:08:05:57 -0700] "GET /mobile_backend/device/2EBE5887-03EA-458A-B4C4-E57253966231/ HTTP/1.1" 500 0 - "Apache-HttpClient/4.2.6 (java 1.5)" "v1.blueberry.xxx-staging.appspot.com" ms=59989 cpu_ms=0 cpm_usd=0.000281 exit_code=119 instance=00c61b117cce7ef8bc8fb86f8aa5315fc96a4d app_engine_release=1.9.20
E 17:05:57.741 Thread running after request. Creation traceback:
File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/runtime/runtime.py", line 152, in HandleRequest
error)
File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/runtime/wsgi.py", line 329, in HandleRequest
return WsgiRequest(environ, handler_name, url, post_data, error).Handle()
File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/runtime/wsgi.py", line 267, in Handle
result = handler(dict(self._environ), self._StartResponse)
File "/base/data/home/apps/s~xxx-staging/blueberry:v1.384273266847676695/lib/django/core/handlers/wsgi.py", line 187, in __call__
response = self.get_response(request)
File "/base/data/home/apps/s~xxx-staging/blueberry:v1.384273266847676695/lib/django/core/handlers/base.py", line 198, in get_response
signals.got_request_exception.send(sender=self.__class__, request=request)
File "/base/data/home/apps/s~xxx-staging/blueberry:v1.384273266847676695/lib/django/dispatch/dispatcher.py", line 198, in send
response = receiver(signal=self, sender=sender, **named)
File "/base/data/home/apps/s~xxx-staging/blueberry:v1.384273266847676695/lib/raven/contrib/django/models.py", line 177, in sentry_exception_handler
client.captureException(exc_info=sys.exc_info(), request=request)
File "/base/data/home/apps/s~xxx-staging/blueberry:v1.384273266847676695/lib/raven/base.py", line 679, in captureException
'raven.events.Exception', exc_info=exc_info, **kwargs)
File "/base/data/home/apps/s~xxx-staging/blueberry:v1.384273266847676695/lib/raven/contrib/django/client.py", line 157, in capture
result = super(DjangoClient, self).capture(event_type, **kwargs)
File "/base/data/home/apps/s~xxx-staging/blueberry:v1.384273266847676695/lib/raven/base.py", line 526, in capture
self.send(**data)
File "/base/data/home/apps/s~xxx-staging/blueberry:v1.384273266847676695/lib/raven/base.py", line 613, in send
return self.send_encoded(message, auth_header=auth_header)
File "/base/data/home/apps/s~xxx-staging/blueberry:v1.384273266847676695/lib/raven/base.py", line 640, in send_encoded
self.send_remote(url=url, data=message, headers=headers)
File "/base/data/home/apps/s~xxx-staging/blueberry:v1.384273266847676695/lib/raven/base.py", line 598, in send_remote
failed_send)
File "/base/data/home/apps/s~xxx-staging/blueberry:v1.384273266847676695/lib/raven/transport/threaded.py", line 169, in async_send
self.get_worker().queue(
File "/base/data/home/apps/s~xxx-staging/blueberry:v1.384273266847676695/lib/raven/transport/threaded.py", line 157, in get_worker
self._worker = AsyncWorker()
File "/base/data/home/apps/s~xxx-staging/blueberry:v1.384273266847676695/lib/raven/transport/threaded.py", line 36, in __init__
self.start()
File "/base/data/home/apps/s~xxx-staging/blueberry:v1.384273266847676695/lib/raven/transport/threaded.py", line 113, in start
self._thread.start()
File "/base/data/home/runtimes/python27/python27_dist/lib/python2.7/threading.py", line 505, in start
_start_new_thread(self.__bootstrap, ())
File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/runtime/runtime.py", line 82, in StartNewThread
return base_start_new_thread(Run, ())
W 17:05:57.743 Threads started by this request continued executing past the hard deadline.
Sentry上正确报告了500错误。如何配置raven以使我的请求超时?
答案 0 :(得分:5)
切换自:
SENTRY_DSN = 'http://public:secret@example.com/1'
到:
SENTRY_DSN = 'sync+http://public:secret@example.com/1'
做了伎俩!
答案 1 :(得分:0)
这对我也很有用:
from raven import Client
from raven.transport.threaded import HTTPTransport
client = Client(
'https://public_key:secret_key@sentry.io/project_id',
transport=HTTPTransport
)
try:
1 / 0
except ZeroDivisionError:
client.captureException()