コード例 #1
0
ファイル: __init__.py プロジェクト: zjw0358/bugsnag-python
    def _handle_request_exception(self, exc):

        options = {
            "user": {
                "id": self.request.remote_ip
            },
            "context": self._get_context(),
            "request": {
                "url": self.request.full_url(),
                "method": self.request.method,
                "arguments": self.request.arguments,
            }
        }

        # Notify bugsnag, unless it's an HTTPError that we specifically want
        # to ignore
        should_notify_bugsnag = True
        if type(exc) == HTTPError:
            ignore_status_codes = self.bugsnag_ignore_status_codes()
            if ignore_status_codes and exc.status_code in ignore_status_codes:
                should_notify_bugsnag = False

        if should_notify_bugsnag:
            bugsnag.auto_notify(exc, **options)

        # Call the parent handler
        RequestHandler._handle_request_exception(self, exc)
コード例 #2
0
ファイル: __init__.py プロジェクト: bugsnag/bugsnag-python
    def _handle_request_exception(self, exc):

        options = {
            "user": {"id": self.request.remote_ip},
            "context": self._get_context(),
            "request": {
                "url": self.request.full_url(),
                "method": self.request.method,
                "arguments": self.request.arguments,
            },
            "severity_reason": {
                "type": "unhandledExceptionMiddleware",
                "attributes": {
                    "framework": "Tornado"
                }
            }
        }

        # Notify bugsnag, unless it's an HTTPError that we specifically want
        # to ignore
        should_notify_bugsnag = True
        if type(exc) == HTTPError:
            ignore_status_codes = self.bugsnag_ignore_status_codes()
            if ignore_status_codes and exc.status_code in ignore_status_codes:
                should_notify_bugsnag = False

        if should_notify_bugsnag:
            bugsnag.auto_notify(exc, **options)

        # Call the parent handler
        RequestHandler._handle_request_exception(self, exc)
コード例 #3
0
    def _handle_request_exception(self, exc: BaseException):
        options = {
            "user": {
                "id": self.request.remote_ip
            },
            "context": self._get_context(),
            "request": {
                "url": self.request.full_url(),
                "method": self.request.method,
                "arguments": self.request.arguments,
            },
            "severity_reason": {
                "type": "unhandledExceptionMiddleware",
                "attributes": {
                    "framework": "Tornado"
                }
            }
        }

        # Notify bugsnag, unless it's an HTTPError that we specifically want
        # to ignore
        should_notify_bugsnag = True
        if isinstance(exc, HTTPError):
            ignore_status_codes = self.bugsnag_ignore_status_codes()
            if ignore_status_codes and exc.status_code in ignore_status_codes:
                should_notify_bugsnag = False

        if should_notify_bugsnag:
            bugsnag.auto_notify(exc, **options)

        # Call the parent handler
        RequestHandler._handle_request_exception(self, exc)  # type: ignore
コード例 #4
0
ファイル: __init__.py プロジェクト: bugsnag/bugsnag-python
def __log_exception(sender, exception, **extra):
    bugsnag.auto_notify(exception, severity_reason={
        "type": "unhandledExceptionMiddleware",
        "attributes": {
            "framework": "Flask"
        }
    })
コード例 #5
0
def __log_exception(sender, exception, **extra):
    bugsnag.auto_notify(exception, severity_reason={
        "type": "unhandledExceptionMiddleware",
        "attributes": {
            "framework": "Flask"
        }
    })
コード例 #6
0
def failure_handler(sender, task_id, exception, args, kwargs, traceback, einfo,
                    **kw):
    task = {"task_id": task_id, "args": args, "kwargs": kwargs}

    bugsnag.auto_notify(exception,
                        traceback=traceback,
                        context=sender.name,
                        extra_data=task)
コード例 #7
0
    def __iter__(self):
        try:
            for response in self.app:
                yield response

        except Exception as e:
            bugsnag.auto_notify(e)
            raise
コード例 #8
0
    def __iter__(self):
        try:
            for response in self.app:
                yield response

        except Exception as e:
            bugsnag.auto_notify(e)
            raise
コード例 #9
0
    def __iter__(self):
        try:
            for response in self.app:
                yield response

        except Exception as e:
            bugsnag.auto_notify(e, severity_reason=self.SEVERITY_REASON)
            raise
コード例 #10
0
 def close(self):
     try:
         if hasattr(self.app, 'close'):
             return self.app.close()
     except Exception as e:
         bugsnag.auto_notify(e)
         raise
     finally:
         bugsnag.clear_request_config()
コード例 #11
0
    def test_auto_notify_defaults(self):
        bugsnag.auto_notify(ScaryException("unexpected failover"))

        json_body = self.server.received[0]['json_body']
        event = json_body['events'][0]
        self.assertTrue(event['unhandled'])
        self.assertEqual(event['severity'], 'error')
        self.assertEqual(event['severityReason'],
                         {"type": "unhandledException"})
コード例 #12
0
 def close(self):
     try:
         if hasattr(self.app, 'close'):
             return self.app.close()
     except Exception as e:
         bugsnag.auto_notify(e)
         raise
     finally:
         bugsnag.clear_request_config()
コード例 #13
0
ファイル: asgi.py プロジェクト: tschoonj/bugsnag-python
 async def __call__(self, scope, receive, send):
     bugsnag.configure_request(asgi_scope=scope)
     try:
         if bugsnag.configuration.auto_capture_sessions:
             bugsnag.start_session()
         await self.app(scope, receive, send)
     except Exception as e:
         bugsnag.auto_notify(e, severity_reason=SEVERITY_REASON)
         raise
コード例 #14
0
 def close(self):
     try:
         if hasattr(self.app, 'close'):
             return self.app.close()
     except Exception as e:
         bugsnag.auto_notify(e, severity_reason=self.SEVERITY_REASON)
         raise
     finally:
         bugsnag.clear_request_config()
コード例 #15
0
ファイル: test_notify.py プロジェクト: bugsnag/bugsnag-python
    def test_auto_notify_defaults(self):
        bugsnag.auto_notify(ScaryException("unexpected failover"))

        json_body = self.server.received[0]['json_body']
        event = json_body['events'][0]
        self.assertTrue(event['unhandled'])
        self.assertEqual(event['severity'], 'error')
        self.assertEqual(event['severityReason'], {
            "type": "unhandledException"
        })
コード例 #16
0
    def process_exception(self, request, exception):
        try:
            bugsnag.auto_notify(exception)

        except Exception:
            bugsnag.logger.exception('Error in exception middleware')

        bugsnag.clear_request_config()

        return None
コード例 #17
0
    def __init__(self, application, environ, start_response):
        self.environ = environ

        bugsnag.configure_request(wsgi_environ=self.environ)

        try:
            self.app = application(environ, start_response)
        except Exception as e:
            bugsnag.auto_notify(e)
            raise
コード例 #18
0
ファイル: middleware.py プロジェクト: zjw0358/bugsnag-python
    def process_exception(self, request, exception):
        try:
            bugsnag.auto_notify(exception)

        except Exception:
            bugsnag.logger.exception('Error in exception middleware')

        bugsnag.clear_request_config()

        return None
コード例 #19
0
ファイル: middleware.py プロジェクト: kylef/bugsnag-python
    def process_exception(self, request, exception):
        try:
            bugsnag.auto_notify(exception)

        except Exception as exc:
            bugsnag.log("Error in exception middleware: %s" % exc)

        bugsnag.clear_request_config()

        return None
コード例 #20
0
    def __init__(self, application, environ, start_response):
        self.environ = environ

        bugsnag.configure_request(wsgi_environ=self.environ)

        try:
            self.app = application(environ, start_response)
        except Exception as e:
            bugsnag.auto_notify(e)
            raise
コード例 #21
0
ファイル: __init__.py プロジェクト: kylef/bugsnag-python
def failure_handler(sender, task_id, exception, args, kwargs, traceback, einfo, **kw):
    task = {
        "task_id": task_id,
        "args": args,
        "kwargs": kwargs
    }

    bugsnag.auto_notify(exception, traceback=traceback,
                              context=sender.name,
                              extra_data=task)
コード例 #22
0
ファイル: middleware.py プロジェクト: eTasku/bugsnag-python
    def process_exception(self, request, exception):
        try:
            bugsnag.auto_notify(exception)

        except Exception as exc:
            bugsnag.log("Error in exception middleware: %s" % exc)

        bugsnag.clear_request_config()

        return None
コード例 #23
0
ファイル: middleware.py プロジェクト: bugsnag/bugsnag-python
    def __iter__(self):
        try:
            for response in self.app:
                yield response

        except Exception as e:
            bugsnag.auto_notify(
                e,
                severity_reason=self.SEVERITY_REASON
            )
            raise
コード例 #24
0
    def __init__(self, application, environ, start_response):
        self.environ = environ

        bugsnag.configure_request(wsgi_environ=self.environ)
        try:
            if bugsnag.configuration.auto_capture_sessions:
                bugsnag.start_session()
            self.app = application(environ, start_response)
        except Exception as e:
            bugsnag.auto_notify(e, severity_reason=self.SEVERITY_REASON)
            raise
コード例 #25
0
ファイル: middleware.py プロジェクト: bugsnag/bugsnag-python
 def close(self):
     try:
         if hasattr(self.app, 'close'):
             return self.app.close()
     except Exception as e:
         bugsnag.auto_notify(
             e,
             severity_reason=self.SEVERITY_REASON
         )
         raise
     finally:
         bugsnag.clear_request_config()
コード例 #26
0
def failure_handler(sender, task_id, exception, args, kwargs, traceback, einfo,
                    **kw):
    task = {"task_id": task_id, "args": args, "kwargs": kwargs}

    bugsnag.auto_notify(exception,
                        traceback=traceback,
                        context=sender.name,
                        extra_data=task,
                        severity_reason={
                            'type': 'unhandledExceptionMiddleware',
                            'attributes': {
                                'framework': 'Celery'
                            }
                        })
コード例 #27
0
ファイル: middleware.py プロジェクト: bugsnag/bugsnag-python
    def __init__(self, application, environ, start_response):
        self.environ = environ

        bugsnag.configure_request(wsgi_environ=self.environ)

        try:
            if bugsnag.configuration.auto_capture_sessions:
                bugsnag.start_session()
            self.app = application(environ, start_response)
        except Exception as e:
            bugsnag.auto_notify(
                e,
                severity_reason=self.SEVERITY_REASON
            )
            raise
コード例 #28
0
ファイル: middleware.py プロジェクト: 8bitduck/bugsnag-python
def handle_exception(exception, env):
    request = Request(env)

    bugsnag.configure_request(
        context="%s %s" % (request.method, request_path(env)),
        user_id=request.remote_addr,
        request_data={
            "url": request.base_url,
            "headers": dict(request.headers),
            "cookies": dict(request.cookies),
            "params": dict(request.form),
        },
        environment_data=dict(request.environ),
    )
    bugsnag.auto_notify(exception)
    bugsnag.clear_request_config()
コード例 #29
0
ファイル: __init__.py プロジェクト: 8bitduck/bugsnag-python
def __log_exception(sender, exception, **extra):
    bugsnag.configure_request(
        context="%s %s" % (request.method, request_path(request.environ)),
        user_id=request.remote_addr,
        request_data={
            "url": request.base_url,
            "headers": dict(request.headers),
            "cookies": dict(request.cookies),
            "params": dict(request.form),
        },
        session_data=dict(session),
        environment_data=dict(request.environ),
    )

    bugsnag.auto_notify(exception)

    bugsnag.clear_request_config()
コード例 #30
0
    def process_exception(self, request, exception):
        try:
            bugsnag.auto_notify(
                exception,
                severity_reason={
                    "type": "unhandledExceptionMiddleware",
                    "attributes": {
                        "framework": "Django"
                    }
                }
            )

        except Exception:
            bugsnag.logger.exception("Error in exception middleware")

        bugsnag.clear_request_config()

        return None
コード例 #31
0
 async def bugsnag_app(self, scope: Scope, receive: Receive,
                       send: Send) -> None:
     bugsnag.configure_request(scope=scope)
     inner = self.app
     try:
         await inner(scope, receive, send)
     except Exception as exc:
         bugsnag.configure_request(frame_locals=self.get_locals(exc))
         bugsnag.auto_notify(exc,
                             severity_reason={
                                 "type": "unhandledExceptionMiddleware",
                                 "attributes": {
                                     "framework": "Starlette"
                                 }
                             })
         raise exc from None
     finally:
         bugsnag.clear_request_config()
コード例 #32
0
def failure_handler(sender, task_id, exception, args, kwargs, traceback, einfo,
                    **kw):
    """
    Overriding configuration in bugsnag.celery in order to set the severity
    to warning instead of error.
    """
    task = {"task_id": task_id, "args": args, "kwargs": kwargs}

    bugsnag.auto_notify(
        exception,
        traceback=traceback,
        context=sender.name,
        extra_data=task,
        severity='warning',  # adding this to original code
        severity_reason={
            'type': 'unhandledExceptionMiddleware',
            'attributes': {
                'framework': 'Celery'
            }
        })
コード例 #33
0
def failure_handler(sender, task_id, exception, args, kwargs, traceback, einfo,
                    **kw):
    """
    Overriding configuration in bugsnag.celery in order to set the severity
    to warning instead of error.
    """
    task = {
        "task_id": task_id,
        "args": args,
        "kwargs": kwargs
    }

    bugsnag.auto_notify(exception, traceback=traceback,
                        context=sender.name,
                        extra_data=task,
                        severity='warning',  # adding this to original code
                        severity_reason={
                            'type': 'unhandledExceptionMiddleware',
                            'attributes': {
                                'framework': 'Celery'
                            }
                        })
コード例 #34
0
    def test_auto_notify_overrides(self):
        bugsnag.auto_notify(ScaryException("unexpected failover"),
                            severity='info',
                            unhandled=False,
                            severity_reason={
                                "type": "middleware_handler",
                                "attributes": {
                                    "name": "test middleware"
                                }
                            })

        json_body = self.server.received[0]['json_body']
        event = json_body['events'][0]
        self.assertFalse(event['unhandled'])
        self.assertEqual(event['severity'], 'info')
        self.assertEqual(
            event['severityReason'], {
                "type": "middleware_handler",
                "attributes": {
                    "name": "test middleware"
                }
            })
コード例 #35
0
ファイル: test_notify.py プロジェクト: bugsnag/bugsnag-python
    def test_auto_notify_overrides(self):
        bugsnag.auto_notify(
            ScaryException("unexpected failover"),
            severity='info',
            unhandled=False,
            severity_reason={
                "type": "middleware_handler",
                "attributes": {
                    "name": "test middleware"
                }
            }
        )

        json_body = self.server.received[0]['json_body']
        event = json_body['events'][0]
        self.assertFalse(event['unhandled'])
        self.assertEqual(event['severity'], 'info')
        self.assertEqual(event['severityReason'], {
            "type": "middleware_handler",
            "attributes": {
                "name": "test middleware"
            }
        })
コード例 #36
0
        def _handle_request_exception(self, exc):

            options = {
                "user": {"ip": self.request.remote_ip, "id": getattr(self, "current_user_id", 0)},
                "context": self._get_context(),
                "request": {
                    "url": self.request.full_url(),
                    "method": self.request.method,
                    "arguments": self.request.arguments,
                }
            }

            # Notify bugsnag, unless it's an HTTPError that we specifically want to ignore
            should_notify_bugsnag = True
            if type(exc) == HTTPError:
                if (exc.status_code<500 and exc.status_code>=400):
                    should_notify_bugsnag = False

            if should_notify_bugsnag:
                bugsnag.auto_notify(exc, **options)

            # Call the parent handler
            _RequestHandler._handle_request_exception(self, exc)
コード例 #37
0
ファイル: __init__.py プロジェクト: kylef/bugsnag-python
    def _handle_request_exception(self, exc):

        options = {
            "user": {"id": self.request.remote_ip},
            "context": self._get_context(),
            "request": {
                "url": self.request.full_url(),
                "method": self.request.method,
                "arguments": self.request.arguments,
            },
        }

        # Notify bugsnag, unless it's an HTTPError that we specifically want to ignore
        should_notify_bugsnag = True
        if type(exc) == HTTPError:
            ignore_status_codes = self.bugsnag_ignore_status_codes()
            if ignore_status_codes and exc.status_code in ignore_status_codes:
                should_notify_bugsnag = False

        if should_notify_bugsnag:
            bugsnag.auto_notify(exc, **options)

        # Call the parent handler
        RequestHandler._handle_request_exception(self, exc)
コード例 #38
0
ファイル: __init__.py プロジェクト: zjw0358/bugsnag-python
def __log_exception(sender, exception, **extra):
    bugsnag.auto_notify(exception)