Example #1
0
    def process_response(self, request, response):
        try:
            if hasattr(response, 'status_code'):
                # check if _opbeat_transaction_name is set
                if hasattr(request, '_opbeat_transaction_name'):
                    transaction_name = request._opbeat_transaction_name
                elif getattr(request, '_opbeat_view_func', False):
                    transaction_name = get_name_from_func(
                        request._opbeat_view_func
                    )
                else:
                    transaction_name = ''

                status_code = response.status_code
                transaction_name = build_name_with_http_method_prefix(
                    transaction_name,
                    request
                )

                self.client.end_transaction(transaction_name, status_code)
        except Exception:
            self.client.error_logger.error(
                'Exception during timing of request',
                exc_info=True,
            )
        return response
Example #2
0
    def process_response(self, request, response):
        try:
            if hasattr(response, 'status_code'):
                # check if _opbeat_transaction_name is set
                if hasattr(request, '_opbeat_transaction_name'):
                    transaction_name = request._opbeat_transaction_name
                elif getattr(request, '_opbeat_view_func', False):
                    transaction_name = get_name_from_func(
                        request._opbeat_view_func)
                else:
                    transaction_name = ''

                status_code = response.status_code
                transaction_name = build_name_with_http_method_prefix(
                    transaction_name, request)
                transaction_data = self.client.get_data_from_request(request)
                self.client.set_transaction_extra_data(
                    transaction_data['http'], 'http')
                if 'user' in transaction_data:
                    self.client.set_transaction_extra_data(
                        transaction_data['user'], 'user')

                self.client.end_transaction(transaction_name, status_code)
        except Exception:
            self.client.error_logger.error(
                'Exception during timing of request',
                exc_info=True,
            )
        return response
Example #3
0
    def __call__(self, func):
        self.name = self.name or get_name_from_func(func)

        @functools.wraps(func)
        def decorated(*args, **kwds):
            with self:
                return func(*args, **kwds)

        return decorated
Example #4
0
    def __call__(self, func):
        self.signature = self.signature or get_name_from_func(func)

        @functools.wraps(func)
        def decorated(*args, **kwds):
            with self:
                return func(*args, **kwds)

        return decorated
Example #5
0
    def process_response(self, request, response):
        try:
            if hasattr(response, 'status_code'):
                if getattr(request, '_opbeat_view_func', False):
                    view_func = get_name_from_func(request._opbeat_view_func)
                else:
                    view_func = getattr(request, '_opbeat_transaction_name',
                                        '')
                status_code = response.status_code
                view_func = build_name_with_http_method_prefix(
                    view_func, request)

                self.client.end_transaction(view_func, status_code)
        except Exception:
            self.client.error_logger.error(
                'Exception during timing of request',
                exc_info=True,
            )
        return response
Example #6
0
    def process_response(self, request, response):
        try:
            if hasattr(response, 'status_code'):
                if getattr(request, '_opbeat_view_func', False):
                    view_func = get_name_from_func(
                        request._opbeat_view_func)
                else:
                    view_func = getattr(
                        request,
                        '_opbeat_transaction_name',
                        ''
                    )
                status_code = response.status_code

                self.client.end_transaction(view_func, status_code)
        except Exception:
            self.client.error_logger.error(
                'Exception during timing of request',
                exc_info=True,
            )
        return response