Esempio n. 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)
Esempio n. 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
Esempio n. 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
Esempio n. 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)
Esempio n. 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()
Esempio n. 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()
Esempio n. 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()
Esempio n. 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()
Esempio n. 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'))
Esempio n. 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'))
Esempio n. 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
Esempio n. 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
Esempio n. 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'])
Esempio n. 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'])
Esempio n. 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'])
Esempio n. 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
Esempio n. 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
Esempio n. 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
Esempio n. 19
0
 def handle_exception(self, *args, **kwargs):
     blueox.set('exception',
                ''.join(traceback.format_exception(*sys.exc_info())))
Esempio n. 20
0
 def test(self):
     blueox.set("foo", True)
Esempio n. 21
0
def on_task_postrun(**kwargs):
    blueox.set('result_state', str(kwargs['state']))

    ctx = current_context()
    if ctx:
        ctx.done()
Esempio n. 22
0
 def prepare(self):
     blueox.set('headers', self.request.headers)
     blueox.set('method', self.request.method)
     blueox.set('uri', self.request.uri)
Esempio n. 23
0
 def test(self):
     with blueox.Context('test', 5):
         blueox.set('foo', True)
Esempio n. 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)
Esempio n. 25
0
def on_task_postrun(**kwargs):
    blueox.set('result_state', str(kwargs['state']))

    ctx = current_context()
    if ctx:
        ctx.done()
Esempio n. 26
0
def on_task_failure(**kwargs):
    blueox.set('exception', "".join(
        traceback.format_exception(*kwargs['einfo'].exc_info)))
Esempio n. 27
0
 def finish(self, *args, **kwargs):
     res = super(SampleRequestHandler, self).finish(*args, **kwargs)
     blueox.set('response_status_code', self._status_code)
     return res
Esempio n. 28
0
 def test(self):
     blueox.set('foo', True)
Esempio n. 29
0
 def process_exception(self, request, exception):
     blueox.set('exception',
                ''.join(traceback.format_exception(*sys.exc_info())))
     return None
Esempio n. 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'])
Esempio n. 31
0
 def test(self):
     blueox.set('foo', True)
Esempio n. 32
0
 def my_function(value):
     blueox.set('value', value)
     self.context = context.current_context()
     return True
Esempio n. 33
0
 def test(self):
     with blueox.Context("test", 5):
         blueox.set("foo", True)
Esempio n. 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'])
Esempio n. 35
0
 def my_function(value):
     blueox.set('value', value)
     self.context = context.current_context()
     return True
Esempio n. 36
0
def on_task_failure(**kwargs):
    blueox.set('exception',
               "".join(traceback.format_exception(*kwargs['einfo'].exc_info)))
Esempio n. 37
0
 def process_exception(self, request, exception):
     blueox.set('exception', ''.join(traceback.format_exception(*sys.exc_info())))
     return None
Esempio n. 38
0
 def on_finish(self):
     blueox.set('response_status_code', self._status_code)
     super(SampleRequestHandler, self).on_finish()
Esempio n. 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)
Esempio n. 40
0
 def on_finish(self):
     blueox.set('response_status_code', self._status_code)
     super(SampleRequestHandler, self).on_finish()
Esempio n. 41
0
 def handle_exception(self, *args, **kwargs):
     blueox.set(
         'exception', ''.join(traceback.format_exception(*sys.exc_info())))
Esempio n. 42
0
 def test(self):
     with blueox.Context('test', 5):
         blueox.set('foo', True)