Пример #1
0
 def process_response(self, request, response):
     if (response.status_code != 404 or
             _is_ignorable_404(request.get_full_path())):
         return response
     if disabled_due_to_debug(
                 getattr(django_settings, 'OPBEAT', {}),
                 django_settings.DEBUG
             ):
         return response
     data = client.get_data_from_request(request)
     data.update({
         'level': logging.INFO,
         'logger': 'http404',
     })
     result = client.capture(
         'Message',
         param_message={
             'message': 'Page Not Found: %s',
             'params': [request.build_absolute_uri()]
         }, data=data
     )
     request.opbeat = {
         'app_id': data.get('app_id', client.app_id),
         'id': client.get_ident(result),
     }
     return response
Пример #2
0
    def handle_exception(self, *args, **kwargs):
        if not self.client:
            return

        if disabled_due_to_debug(self.app.config.get('OPBEAT', {}),
                                 self.app.config.get('DEBUG', False)):
            return

        self.client.capture(
            'Exception',
            exc_info=kwargs.get('exc_info'),
            data=get_data_from_request(request),
            extra={
                'app': self.app,
            },
        )
Пример #3
0
    def handle_exception(self, *args, **kwargs):
        if not self.client:
            return

        if disabled_due_to_debug(
            self.app.config.get('OPBEAT', {}),
            self.app.config.get('DEBUG', False)
        ):
            return

        self.client.capture('Exception', exc_info=kwargs.get('exc_info'),
            data=get_data_from_request(request),
            extra={
                'app': self.app,
            },
        )
Пример #4
0
    def actually_do_stuff(request=None, **kwargs):
        exc_info = sys.exc_info()
        try:
            if (disabled_due_to_debug(getattr(django_settings, 'OPBEAT', {}),
                                      django_settings.DEBUG)
                    or getattr(exc_info[1], 'skip_opbeat', False)):
                return

            get_client().capture('Exception',
                                 exc_info=exc_info,
                                 request=request)
        except Exception as exc:
            try:
                logger.exception(u'Unable to process log entry: %s' % (exc, ))
            except Exception as exc:
                warnings.warn(u'Unable to process log entry: %s' % (exc, ))
        finally:
            try:
                del exc_info
            except Exception as e:
                logger.exception(e)
Пример #5
0
    def actually_do_stuff(request=None, **kwargs):
        exc_info = sys.exc_info()
        try:
            if (disabled_due_to_debug(
                    getattr(django_settings, 'OPBEAT', {}),
                    django_settings.DEBUG)
                    or getattr(exc_info[1], 'skip_opbeat', False)):
                return

            get_client().capture(
                'Exception', exc_info=exc_info, request=request)
        except Exception as exc:
            try:
                logger.exception(u'Unable to process log entry: %s' % (exc, ))
            except Exception as exc:
                warnings.warn(u'Unable to process log entry: %s' % (exc, ))
        finally:
            try:
                del exc_info
            except Exception as e:
                logger.exception(e)
Пример #6
0
 def process_response(self, request, response):
     if (response.status_code != 404
             or _is_ignorable_404(request.get_full_path())):
         return response
     if disabled_due_to_debug(getattr(django_settings, 'OPBEAT', {}),
                              django_settings.DEBUG):
         return response
     data = client.get_data_from_request(request)
     data.update({
         'level': logging.INFO,
         'logger': 'http404',
     })
     result = client.capture('Message',
                             param_message={
                                 'message': 'Page Not Found: %s',
                                 'params': [request.build_absolute_uri()]
                             },
                             data=data)
     request.opbeat = {
         'app_id': data.get('app_id', client.app_id),
         'id': client.get_ident(result),
     }
     return response
Пример #7
0
 def process_request(self, request):
     if not disabled_due_to_debug(
         getattr(django_settings, 'OPBEAT', {}),
         django_settings.DEBUG
     ):
         self.client.begin_transaction()
Пример #8
0
from opbeat.middleware import Opbeat
from opbeat.utils import disabled_due_to_debug

import perma.settings

opbeat_disabled = disabled_due_to_debug(getattr(perma.settings, 'OPBEAT', {}),
                                        perma.settings.DEBUG)


class PywbOpbeatMiddleware(Opbeat):
    def __call__(self, environ, start_response):

        start_response_args = {}
        try:
            if not opbeat_disabled:
                self.client.begin_transaction("web.pywb")

            def start_response_wrapper(status,
                                       response_headers,
                                       exc_info=None):
                start_response_args['status'] = status
                start_response_args['response_headers'] = response_headers
                start_response_args['exc_info'] = exc_info
                return start_response(status, response_headers, exc_info)

            for event in self.application(environ, start_response_wrapper):
                yield event

        finally:
            try:
                if start_response_args:
Пример #9
0
from opbeat.middleware import Opbeat
from opbeat.utils import disabled_due_to_debug

import perma.settings

opbeat_disabled = disabled_due_to_debug(
    getattr(perma.settings, 'OPBEAT', {}),
    perma.settings.DEBUG
)

class PywbOpbeatMiddleware(Opbeat):
    def __call__(self, environ, start_response):

        start_response_args = {}
        try:
            if not opbeat_disabled:
                self.client.begin_transaction("web.pywb")

            def start_response_wrapper(status, response_headers, exc_info=None):
                start_response_args['status'] = status
                start_response_args['response_headers'] = response_headers
                start_response_args['exc_info'] = exc_info
                return start_response(status, response_headers, exc_info)

            for event in self.application(environ, start_response_wrapper):
                yield event

        finally:
            try:
                if start_response_args:
                    status = int(start_response_args['status'].split(' ', 1)[0])