Example #1
0
def should_ignore(exc, value, tb):
    from tornado.web import HTTPError

    if exc is HTTPError:
        status_code = value.status_code
        if ignore_status_code(status_code):
            return True
Example #2
0
def error_response(wrapped, instance, args, kwargs):
    transaction = current_transaction()

    if transaction is None:
        return wrapped(*args, **kwargs)

    exc_info = sys.exc_info()
    try:
        response = wrapped(*args, **kwargs)
    except:
        transaction.record_exception(*exc_info)
        # We record the original exception and the exception generated by the
        # error handler
        transaction.record_exception()
        raise
    else:
        # response can be a response object or a coroutine
        if hasattr(response, 'status'):
            if not ignore_status_code(response.status):
                transaction.record_exception(*exc_info)
        else:
            transaction.record_exception(*exc_info)
    finally:
        exc_info = None

    return response
Example #3
0
def record_exception(exc_info):
    # Record the details of any exception ignoring status codes which
    # have been configured to be ignored.

    import tornado.web

    exc = exc_info[0]
    value = exc_info[1]

    # Not an error so we just return.
    if exc is tornado.web.Finish:
        return

    if exc is tornado.web.HTTPError:
        if ignore_status_code(value.status_code):
            return

    transaction = retrieve_current_transaction()
    if transaction:
        transaction.record_exception(*exc_info)
    else:
        # If we are not in a transaction we record the exception to the default
        # application specified in the agent configuration.
        application = application_instance()
        if application and application.enabled:
            application.record_exception(*exc_info)
Example #4
0
def should_ignore(exc, value, tb):
    from cherrypy import HTTPError, HTTPRedirect

    # Ignore certain exceptions based on HTTP status codes.

    if isinstance(value, (HTTPError, HTTPRedirect)):
        # In the case of an HTTPRedirect, value will not have a code attr.
        # In the case of an HTTPError that is malformed (e.g.
        # HTTPError("10 Bad error")), value will not have a code attr.
        # In both of those cases, we fall back to value.status
        code = getattr(value, 'code', value.status)

        if ignore_status_code(code):
            return True

    # Ignore certain exceptions based on their name.

    module = value.__class__.__module__
    name = value.__class__.__name__
    fullname = '%s:%s' % (module, name)

    ignore_exceptions = ('cherrypy._cperror:InternalRedirect',)

    if fullname in ignore_exceptions:
        return True
def record_response_error(response, value):
    status_code = getattr(response, "status_code", None)
    exc = getattr(value, "__class__", None)
    tb = getattr(value, "__traceback__", None)
    if ignore_status_code(status_code):
        value._nr_ignored = True
    else:
        record_exception(exc, value, tb)
Example #6
0
def _nr_wrap_handle_exception(wrapped, instance, args, kwargs):

    response = wrapped(*args, **kwargs)

    if not ignore_status_code(response.status_code):
        record_exception()

    return response
Example #7
0
def should_ignore(exc, value, tb):
    # The HTTPError class derives from HTTPResponse and so we do not
    # need to check for it seperately as isinstance() will pick it up.

    if isinstance(value, module_bottle.HTTPResponse):
        if hasattr(value, 'status_code'):
            if ignore_status_code(value.status_code):
                return True
        elif hasattr(value, 'status'):
            if ignore_status_code(value.status):
                return True
        elif hasattr(value, 'http_status_code'):
            if ignore_status_code(value.http_status_code):
                return True

    elif hasattr(module_bottle, 'RouteReset'):
        if isinstance(value, module_bottle.RouteReset):
            return True
Example #8
0
def _nr_wrap_handle_exception(wrapped, instance, args, kwargs):

    response = wrapped(*args, **kwargs)

    if not ignore_status_code(response.status_code):
        transaction = current_transaction()
        if transaction:
            transaction.record_exception(*sys.exc_info())

    return response
Example #9
0
def should_ignore(exc, value, tb):
    from werkzeug.exceptions import HTTPException

    # Werkzeug HTTPException can be raised internally by Flask or in
    # user code if they mix Flask with Werkzeug. Filter based on the
    # HTTP status code.

    if isinstance(value, HTTPException):
        if ignore_status_code(value.code):
            return True
Example #10
0
def record_exception(transaction, exc_info):
    # Record the details of any exception ignoring status codes which
    # have been configured to be ignored.

    import tornado.web

    exc = exc_info[0]
    value = exc_info[1]

    if exc is tornado.web.HTTPError:
        if ignore_status_code(value.status_code):
            return

    transaction.record_exception(*exc_info)
Example #11
0
def _nr_wrapper_BaseHandler_get_response_(wrapped, instance, args, kwargs):
    response = wrapped(*args, **kwargs)

    if current_transaction() is None:
        return response

    request = _bind_get_response(*args, **kwargs)

    if hasattr(request, '_nr_exc_info'):
        if not ignore_status_code(response.status_code):
            record_exception(*request._nr_exc_info)
        delattr(request, '_nr_exc_info')

    return response
def should_ignore(exc, value, tb):
    from pyramid.httpexceptions import HTTPException
    from pyramid.exceptions import PredicateMismatch

    # Ignore certain exceptions based on HTTP status codes.

    if isinstance(value, HTTPException):
        if ignore_status_code(value.code):
            return True

    # Always ignore PredicateMismatch as it is raised by views to force
    # subsequent views to be consulted when multi views are being used.
    # It isn't therefore strictly an error as such as a subsequent view
    # could still handle the request. See TODO items though for a corner
    # case where this can mean an error isn't logged when it should.

    if isinstance(value, PredicateMismatch):
        return True
Example #13
0
def should_ignore(exc, value, tb):
    from cherrypy import HTTPError, HTTPRedirect

    # Ignore certain exceptions based on HTTP status codes.

    if isinstance(value, (HTTPError, HTTPRedirect)):
        if ignore_status_code(value.status):
            return True

    # Ignore certain exceptions based on their name.

    module = value.__class__.__module__
    name = value.__class__.__name__
    fullname = '%s:%s' % (module, name)

    ignore_exceptions = ('cherrypy._cperror:InternalRedirect',)

    if fullname in ignore_exceptions:
        return True
Example #14
0
    def wrap_handle_exception(wrapped, instance, args, kwargs):
        transaction = current_transaction()

        if transaction is None:
            return wrapped(*args, **kwargs)

        name = callable_name(wrapped)
        transaction.set_transaction_name(name, priority=1)

        result = wrapped(*args, **kwargs)
        if result:
            exc_info = sys.exc_info()
            try:
                resp = bind_handle_exception(*args, **kwargs)
                response_code = int(resp.status.split()[0])
                if ignore_status_code(response_code):
                    return result
                record_exception(*exc_info)
            except:
                record_exception(*exc_info)
            finally:
                exc_info = None

        return result
Example #15
0
def should_ignore(exc, value, tb):
    from aiohttp import web

    if isinstance(value, web.HTTPException):
        status_code = value.status_code
        return ignore_status_code(status_code)
def should_ignore(exc, value, tb):
    from django.http import Http404

    if isinstance(value, Http404):
        if ignore_status_code(404):
            return True