示例#1
0
    def write_error(self, status_code, **kwargs):
        if 'exc_info' in kwargs:
            blueox.set('exception',
                       ''.join(traceback.format_exception(*kwargs["exc_info"])))

        return super(SampleRequestHandler, self).write_error(status_code,
                                                             **kwargs)
示例#2
0
    def process_response(self, request, response):
        # process_request() is not guaranteed to be called
        if not hasattr(request, 'blueox'):
            return response

        # We collect some additional data in the response, just to ensure
        # middleware ordering doesn't matter.
        if hasattr(request, 'user'):
            blueox.set('user', request.user.id)

        for key in ('version', 'revision'):
            if hasattr(request, key):
                blueox.set(key, getattr(request, key))

        # Other middleware may have blocked our response.
        if response is not None:

            blueox.set('response_status_code', response.status_code)

            if not response.streaming:
                blueox.set('response_size', len(response.content))

            headers = {}
            for k, v in response.items():
                headers[k] = v

            blueox.set('response_headers', headers)

        request.blueox.done()

        return response
示例#3
0
    def process_response(self, request, response):
        # process_request() is not guaranteed to be called
        if not hasattr(request, 'blueox'):
            return response

        # We collect some additional data in the response, just to ensure
        # middleware ordering doesn't matter.
        if hasattr(request, 'user'):
            blueox.set('user', request.user.id)

        for key in ('version', 'revision'):
            if hasattr(request, key):
                blueox.set(key, getattr(request, key))

        # Other middleware may have blocked our response.
        if response is not None:

            blueox.set('response_status_code', response.status_code)

            if not response.streaming:
                blueox.set('response_size', len(response.content))

            headers = {}
            for k, v in response.items():
                headers[k] = v

            blueox.set('response_headers', headers)

        request.blueox.done()

        return response
示例#4
0
    def write_error(self, status_code, **kwargs):
        if 'exc_info' in kwargs:
            blueox.set(
                'exception',
                ''.join(traceback.format_exception(*kwargs["exc_info"])))

        return super(SampleRequestHandler,
                     self).write_error(status_code, **kwargs)
示例#5
0
    def _complete_get(self):
        self.blueox.start()

        with blueox.Context('request.extra'):
            blueox.set('continue_id', self.blueox.id)

        self.write("Hello, world")
        self.finish()
示例#6
0
def on_task_retry(**kwargs):
    blueox.set('result_state', states.RETRY)

    blueox.set('exception',
               "".join(traceback.format_exception(*kwargs['einfo'].exc_info)))

    # Retry path doesn't call 'postrun'. I think in celery-speak, it's the same
    # task, but we want to track attempts.
    ctx = current_context()
    if ctx:
        ctx.done()
示例#7
0
def on_task_retry(**kwargs):
    blueox.set('result_state', states.RETRY)

    blueox.set('exception', "".join(
        traceback.format_exception(*kwargs['einfo'].exc_info)))

    # Retry path doesn't call 'postrun'. I think in celery-speak, it's the same
    # task, but we want to track attempts.
    ctx = current_context()
    if ctx:
        ctx.done()
示例#8
0
    def get(self):
        loop = tornado.ioloop.IOLoop.instance()

        req_id = self.blueox.id

        called = yield tornado.gen.Task(loop.add_timeout, time.time() + random.randint(1, 5))

        with blueox.Context('.extra'):
            blueox.set('continue_id', req_id)

        self.write("Hello, world")
        self.finish()
示例#9
0
    def before_request(self, *args, **kwargs):
        request.blueox = blueox.Context(".".join(
            (self.app.config.get('BLUEOX_NAME', ''), 'request')))

        blueox.set('method', request.method)
        blueox.set('path', request.path)

        headers = {}
        for k, v in request.environ.iteritems():
            if (k.startswith('HTTP_')
                    or k in ('CONTENT_LENGTH', 'CONTENT_TYPE')):
                headers[k] = v

        blueox.set('headers', headers)
        blueox.set('url', request.url)
        blueox.set('client_ip', request.environ.get('REMOTE_ADDR'))
示例#10
0
    def before_request(self, *args, **kwargs):
        request.blueox = blueox.Context(
            ".".join((self.app.config.get('BLUEOX_NAME', ''), 'request')))

        blueox.set('method', request.method)
        blueox.set('path', request.path)

        headers = {}
        for k, v in request.environ.iteritems():
            if (
                k.startswith('HTTP_') or k in
                ('CONTENT_LENGTH', 'CONTENT_TYPE')):
                headers[k] = v

        blueox.set('headers', headers)
        blueox.set('url', request.url)
        blueox.set('client_ip', request.environ.get('REMOTE_ADDR'))
示例#11
0
    def process_request(self, request):
        request.blueox = blueox.Context(".".join((getattr(settings, 'BLUEOX_NAME', ''), 'request')))
        request.blueox.start()

        blueox.set('method', request.method)
        blueox.set('path', request.path)

        headers = {}
        for k,v in request.META.iteritems():
            if k.startswith('HTTP_') or k in ('CONTENT_LENGTH', 'CONTENT_TYPE'):
                headers[k] = v
        blueox.set('headers', headers)

        blueox.set('uri', request.build_absolute_uri())
        blueox.set('client_ip', request.META['REMOTE_ADDR'])

        return None
示例#12
0
    def process_request(self, request):
        request.blueox = blueox.Context(".".join(
            (getattr(settings, 'BLUEOX_NAME', ''), 'request')))
        request.blueox.start()

        blueox.set('method', request.method)
        blueox.set('path', request.path)

        headers = {}
        for k, v in request.META.iteritems():
            if k.startswith('HTTP_') or k in ('CONTENT_LENGTH',
                                              'CONTENT_TYPE'):
                headers[k] = v
        blueox.set('headers', headers)

        blueox.set('uri', request.build_absolute_uri())
        blueox.set('client_ip', request.META['REMOTE_ADDR'])

        return None
示例#13
0
def on_task_sent(**kwargs):
    with blueox.Context('.celery.task_sent'):
        # Arguments for this signal are different than the worker signals. Sometimes
        # they are even different than what the documentation says.
        blueox.set('task_id', kwargs.get('task_id', kwargs['id']))
        blueox.set('task', str(kwargs['task']))
        blueox.set('eta', kwargs['eta'])
示例#14
0
 def on_task_sent(**kwargs):
     with blueox.Context('.celery.task_sent'):
         # Arguments for this signal are different than the worker signals. Sometimes
         # they are even different than what the documentation says. See also
         # https://github.com/celery/celery/issues/1606
         blueox.set('task_id', kwargs.get('task_id', kwargs.get('id')))
         blueox.set('task', str(kwargs['task']))
         blueox.set('eta', kwargs['eta'])
示例#15
0
 def on_task_sent(**kwargs):
     with blueox.Context('.celery.task_sent'):
         # Arguments for this signal are different than the worker signals. Sometimes
         # they are even different than what the documentation says. See also
         # https://github.com/celery/celery/issues/1606
         blueox.set('task_id', kwargs.get('task_id', kwargs.get('id')))
         blueox.set('task', str(kwargs['task']))
         blueox.set('eta', kwargs['eta'])
示例#16
0
    def after_request(self, response):
        if not hasattr(request, 'blueox'):
            return

        if hasattr(request, 'user'):
            blueox.set('user', request.user.id)

        for key in ('version', 'revision'):
            if hasattr(request, key):
                blueox.set(key, getattr(request, key))

        if response is not None:
            blueox.set('response_status_code', response.status_code)

            if not response.is_streamed:
                blueox.set('response_size', response.content_length)

        request.blueox.done()

        return response
示例#17
0
    def after_request(self, response):
        if not hasattr(request, 'blueox'):
            return

        if hasattr(request, 'user'):
            blueox.set('user', request.user.id)

        for key in ('version', 'revision'):
            if hasattr(request, key):
                blueox.set(key, getattr(request, key))

        if response is not None:
            blueox.set('response_status_code', response.status_code)

            if not response.is_streamed:
                blueox.set('response_size', response.content_length)

        request.blueox.done()

        return response
示例#18
0
    def process_response(self, request, response):
        # process_request() is not guaranteed to be called
        if not hasattr(request, 'blueox'):
            return response

        # Other middleware may have blocked our response.
        if response is not None:
            blueox.set('response_status_code', response.status_code)

            if not response.streaming:
                blueox.set('response_size', len(response.content))

            headers = {}
            for k, v in response.items():
                headers[k] = v

            blueox.set('response_headers', headers)

        request.blueox.done()

        return response
示例#19
0
 def handle_exception(self, *args, **kwargs):
     blueox.set('exception',
                ''.join(traceback.format_exception(*sys.exc_info())))
示例#20
0
 def test(self):
     blueox.set("foo", True)
示例#21
0
def on_task_postrun(**kwargs):
    blueox.set('result_state', str(kwargs['state']))

    ctx = current_context()
    if ctx:
        ctx.done()
示例#22
0
 def prepare(self):
     blueox.set('headers', self.request.headers)
     blueox.set('method', self.request.method)
     blueox.set('uri', self.request.uri)
示例#23
0
 def test(self):
     with blueox.Context('test', 5):
         blueox.set('foo', True)
示例#24
0
 def prepare(self):
     super(SampleRequestHandler, self).prepare()
     blueox.set('headers', self.request.headers)
     blueox.set('method', self.request.method)
     blueox.set('uri', self.request.uri)
示例#25
0
def on_task_postrun(**kwargs):
    blueox.set('result_state', str(kwargs['state']))

    ctx = current_context()
    if ctx:
        ctx.done()
示例#26
0
def on_task_failure(**kwargs):
    blueox.set('exception', "".join(
        traceback.format_exception(*kwargs['einfo'].exc_info)))
示例#27
0
 def finish(self, *args, **kwargs):
     res = super(SampleRequestHandler, self).finish(*args, **kwargs)
     blueox.set('response_status_code', self._status_code)
     return res
示例#28
0
 def test(self):
     blueox.set('foo', True)
示例#29
0
 def process_exception(self, request, exception):
     blueox.set('exception',
                ''.join(traceback.format_exception(*sys.exc_info())))
     return None
示例#30
0
 def on_task_sent(sender=None, body=None, **kwargs):
     with blueox.Context('.celery.task_sent'):
         blueox.set('task_id', body['id'])
         blueox.set('task', str(body['task']))
         blueox.set('eta', body['eta'])
示例#31
0
 def test(self):
     blueox.set('foo', True)
示例#32
0
 def my_function(value):
     blueox.set('value', value)
     self.context = context.current_context()
     return True
示例#33
0
 def test(self):
     with blueox.Context("test", 5):
         blueox.set("foo", True)
示例#34
0
 def on_task_sent(sender=None, body=None, **kwargs):
     with blueox.Context('.celery.task_sent'):
         blueox.set('task_id', body['id'])
         blueox.set('task', str(body['task']))
         blueox.set('eta', body['eta'])
示例#35
0
 def my_function(value):
     blueox.set('value', value)
     self.context = context.current_context()
     return True
示例#36
0
def on_task_failure(**kwargs):
    blueox.set('exception',
               "".join(traceback.format_exception(*kwargs['einfo'].exc_info)))
示例#37
0
 def process_exception(self, request, exception):
     blueox.set('exception', ''.join(traceback.format_exception(*sys.exc_info())))
     return None
示例#38
0
 def on_finish(self):
     blueox.set('response_status_code', self._status_code)
     super(SampleRequestHandler, self).on_finish()
示例#39
0
 def prepare(self):
     super(SampleRequestHandler, self).prepare()
     blueox.set('headers', self.request.headers)
     blueox.set('method', self.request.method)
     blueox.set('uri', self.request.uri)
示例#40
0
 def on_finish(self):
     blueox.set('response_status_code', self._status_code)
     super(SampleRequestHandler, self).on_finish()
示例#41
0
 def handle_exception(self, *args, **kwargs):
     blueox.set(
         'exception', ''.join(traceback.format_exception(*sys.exc_info())))
示例#42
0
 def test(self):
     with blueox.Context('test', 5):
         blueox.set('foo', True)