예제 #1
0
    def deliver(self):
        """
        Deliver the exception notification to Bugsnag.
        """
        url = self.config.get_endpoint()

        try:
            if self.config.api_key is None:
                bugsnag.log("No API key configured, couldn't notify")
                return

            # Return early if we shouldn't notify for current release stage
            if not self.config.should_notify():
                return

            # Return early if we should ignore exceptions of this type
            if self.config.should_ignore(self.exception):
                return

            # Generate the payload and make the request
            bugsnag.log("Notifying %s of exception" % url)

            payload = self.__generate_payload().encode('utf-8', errors='replace')
            req = Request(url, payload, {
                'Content-Type': 'application/json'
            })
            threading.Thread(target=request, args=(req,)).start()

        except Exception:
            exc = traceback.format_exc()
            bugsnag.warn("Notification to %s failed:\n%s" % (url, exc))
    def _send_to_bugsnag(self):
        # Generate the payload and make the request
        url = self.config.get_endpoint()
        async = self.config.asynchronous

        bugsnag.log("Notifying %s of exception" % url)

        deliver(self._payload(), url, async)
예제 #3
0
    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
예제 #4
0
    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
예제 #5
0
def request(req):
    try:
        resp = urlopen(req)
        status = resp.getcode()

        if status != 200:
            bugsnag.log("Notification to %s failed, status %d" % status)

    except Exception:
        bugsnag.log("Notification to %s failed" % (req.get_full_url()))
        print((traceback.format_exc()))
예제 #6
0
    def request():
        try:
            resp = urlopen(req)
            status = resp.getcode()

            if status != 200:
                bugsnag.log("Notification to %s failed, status %d" % (url, status))

        except Exception:
            try:
                bugsnag.log("Notification to %s failed" % (req.get_full_url()))
                print((traceback.format_exc()))
            except Exception:
                print(("[BUGSNAG] error in request thread exception handler."))
                pass
예제 #7
0
    def request():
        try:
            resp = urlopen(req)
            status = resp.getcode()

            if status != 200:
                bugsnag.log("Notification to %s failed, status %d" %
                            (url, status))

        except Exception:
            try:
                bugsnag.log("Notification to %s failed" % (req.get_full_url()))
                print((traceback.format_exc()))
            except Exception:
                print(("[BUGSNAG] error in request thread exception handler."))
                pass
예제 #8
0
    def process_request(self, request):
        if is_development_server(request):
            bugsnag.configure(release_stage="development")

        try:
            bugsnag.configure_request(
                context=request.path,
                user_id=get_user_id(request),
                session_data=dict(request.session),
                request_data={
                    'path': request.path,
                    'encoding': request.encoding,
                    'params': dict(request.REQUEST),
                    'url': request.build_absolute_uri(),
                },
                environment_data=dict(request.META),
            )

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

        return None
예제 #9
0
    def deliver(self):
        """
        Deliver the exception notification to Bugsnag.
        """

        try:
            # Return early if we shouldn't notify for current release stage
            if not self.config.should_notify():
                return

            if self.api_key is None:
                bugsnag.log("No API key configured, couldn't notify")
                return

            # Return early if we should ignore exceptions of this type
            if self.config.should_ignore(self.exception):
                return

            self.config.middleware.run(self, self._send_to_bugsnag)

        except Exception:
            exc = traceback.format_exc()
            bugsnag.warn("Notifying Bugsnag failed:\n%s" % (exc))
예제 #10
0
    def deliver(self):
        """
        Deliver the exception notification to Bugsnag.
        """

        try:
            # Return early if we shouldn't notify for current release stage
            if not self.config.should_notify():
                return

            if self.api_key is None:
                bugsnag.log("No API key configured, couldn't notify")
                return

            # Return early if we should ignore exceptions of this type
            if self.config.should_ignore(self.exception):
                return

            self.config.middleware.run(self, self._send_to_bugsnag)

        except Exception:
            exc = traceback.format_exc()
            bugsnag.warn("Notifying Bugsnag failed:\n%s" % (exc))
예제 #11
0
    def run(self, notification, callback):
        """
        Run all the middleware in order, then call the callback.
        """

        # the last step in the notification stack is to call the callback.
        # we also do this inside the exception handler, so need to ensure that
        # the callback is only called once.
        def finish(notification):
            if not hasattr(finish, 'called'):
                finish.called = True
                callback()

        to_call = finish
        for middleware in reversed(self.stack):
            to_call = middleware(to_call)

        try:
            to_call(notification)
        except Exception as exc:
            bugsnag.log("Error in exception middleware: %s" % exc)
            # still notify if middleware crashes before notification
            finish(notification)
예제 #12
0
    def run(self, notification, callback):
        """
        Run all the middleware in order, then call the callback.
        """

        # the last step in the notification stack is to call the callback.
        # we also do this inside the exception handler, so need to ensure that
        # the callback is only called once.
        def finish(notification):
            if not hasattr(finish, 'called'):
                finish.called = True
                callback()

        to_call = finish
        for middleware in reversed(self.stack):
            to_call = middleware(to_call)

        try:
            to_call(notification)
        except Exception as exc:
            bugsnag.log("Error in exception middleware: %s" % exc)
            # still notify if middleware crashes before notification
            finish(notification)
예제 #13
0
                self.context,
                "groupingHash":
                self.grouping_hash,
                "exceptions": [{
                    "errorClass": class_name(self.exception),
                    "message": str(self.exception),
                    "stacktrace": self.stacktrace,
                }],
                "metaData":
                self.meta_data,
                "user":
                self.user,
                "device": {
                    "hostname": self.hostname
                },
                "projectRoot":
                self.config.get("project_root"),
                "libRoot":
                self.config.get("lib_root")
            }]
        }

    def _send_to_bugsnag(self):
        # Generate the payload and make the request
        url = self.config.get_endpoint()
        async = self.config. async

        bugsnag.log("Notifying %s of exception" % url)

        deliver(self._payload(), url, async)
예제 #14
0
    def _send_to_bugsnag(self):
        # Generate the payload and make the request
        url = self.config.get_endpoint()
        bugsnag.log("Notifying %s of exception" % url)

        deliver(self._payload(), url)
예제 #15
0
            "events": [{
                "payloadVersion": self.PAYLOAD_VERSION,
                "severity": self.severity,
                "releaseStage": self.release_stage,
                "appVersion": self.app_version,
                "context": self.context,
                "groupingHash": self.grouping_hash,
                "exceptions": [{
                    "errorClass": class_name(self.exception),
                    "message": str(self.exception),
                    "stacktrace": self.stacktrace,
                }],
                "metaData": self.meta_data,
                "user": self.user,
                "device": {
                    "hostname": self.hostname
                },
                "projectRoot": self.config.get("project_root"),
                "libRoot": self.config.get("lib_root")
            }]
        }

    def _send_to_bugsnag(self):
        # Generate the payload and make the request
        url = self.config.get_endpoint()
        async = self.config.async

        bugsnag.log("Notifying %s of exception" % url)

        deliver(self._payload(), url, async)