曾与蒿藜同雨露,한때 잡초와 쑥과 함께 비와 이슬을 나누던 곳이 이제는 소나무와 삼나무와 함께 서리와 눈을 견뎌내고 있다.终随松柏到冰霜.かつては雑草やヨモギと共に雨や露を分かち合っていたが、今では松やヒノキと共に霜や雪に耐えている。曾与蒿藜同雨露,Once sharing rain and dew with weeds and wormwood, now enduring frost and snow with pines and cypresses.终随松柏到冰霜.曾与蒿藜同雨露한때 잡초와 쑥과 함께 비와 이슬을 나누던 곳이 이제는 소나무와 삼나무와 함께 서리와 눈을 견뎌내고 있다.,终随松柏到冰霜.譖セ荳手珍阯懷酔髮ィ髴イ�檎サ磯囂譚セ譟丞芦蜀ー髴�曾与蒿藜同雨露,鏇句笌钂胯棞鍚岄洦闇诧紝缁堥殢鏉炬煆鍒板啺闇�终随松柏到冰霜.曾与蒿藜同雨露,한때 잡초와 쑥과 함께 비와 이슬을 나누던 곳이 이제는 소나무와 삼나무와 함께 서리와 눈을 견뎌내고 있다.终随松柏到冰霜.曾与蒿藜同雨露,终随松柏到冰霜.
"""
raven.contrib.zerorpc
~~~~~~~~~~~~~~~~~~~~~
:copyright: (c) 2010-2013 by the Sentry Team, see AUTHORS for more details.
:license: BSD, see LICENSE for more details.
"""
from __future__ import absolute_import
import inspect
from raven.base import Client
class SentryMiddleware(object):
"""Sentry/Raven middleware for ZeroRPC.
>>> import zerorpc
>>> from raven.contrib.zerorpc import SentryMiddleware
>>> sentry = SentryMiddleware(dsn='udp://..../')
>>> zerorpc.Context.get_instance().register_middleware(sentry)
Exceptions detected server-side in ZeroRPC will be submitted to Sentry (and
propagated to the client as well).
"""
def __init__(self, hide_zerorpc_frames=True, client=None, **kwargs):
"""
Create a middleware object that can be injected in a ZeroRPC server.
- hide_zerorpc_frames: modify the exception stacktrace to remove the
internal zerorpc frames (True by default to make
the stacktrace as readable as possible);
- client: use an existing raven.Client object, otherwise one will be
instantiated from the keyword arguments.
"""
self._sentry_client = client or Client(**kwargs)
self._hide_zerorpc_frames = hide_zerorpc_frames
def server_inspect_exception(self, req_event, rep_event, task_ctx, exc_info):
"""
Called when an exception has been raised in the code run by ZeroRPC
"""
# Hide the zerorpc internal frames for readability, for a REQ/REP or
# REQ/STREAM server the frames to hide are:
# - core.ServerBase._async_task
# - core.Pattern*.process_call
# - core.DecoratorBase.__call__
#
# For a PUSH/PULL or PUB/SUB server the frame to hide is:
# - core.Puller._receiver
if self._hide_zerorpc_frames:
traceback = exc_info[2]
while traceback:
zerorpc_frame = traceback.tb_frame
zerorpc_frame.f_locals['__traceback_hide__'] = True
frame_info = inspect.getframeinfo(zerorpc_frame)
# Is there a better way than this (or looking up the filenames
# or hardcoding the number of frames to skip) to know when we
# are out of zerorpc?
if frame_info.function == '__call__' \
or frame_info.function == '_receiver':
break
traceback = traceback.tb_next
self._sentry_client.captureException(
exc_info,
extra=task_ctx
)