예제 #1
0
 def _error_handler(self, crash_data, exc_info, extra):
     """Captures errors from signature generation"""
     extra['uuid'] = crash_data.get('uuid', None)
     raven_client.capture_error(self.sentry_dsn,
                                self.config.logger,
                                exc_info=exc_info,
                                extra=extra)
예제 #2
0
    def _capture_error(self, crash_id, exc_info):
        """Capture an error in sentry if able

        :arg crash_id: a crash id
        :arg exc_info: the exc info as it comes from sys.exc_info()

        """
        if self.config.sentry and self.config.sentry.dsn:
            sentry_dsn = self.config.sentry.dsn
        else:
            sentry_dsn = None

        raven_client.capture_error(sentry_dsn,
                                   self.config.logger,
                                   exc_info,
                                   extra={'crash_id': crash_id})
예제 #3
0
    def _capture_error(self, crash_id, exc_info):
        """Capture an error in sentry if able.

        :arg crash_id: a crash id
        :arg exc_info: the exc info as it comes from sys.exc_info()

        """
        if self.config.sentry and self.config.sentry.dsn:
            sentry_dsn = self.config.sentry.dsn
        else:
            sentry_dsn = None

        raven_client.capture_error(
            sentry_dsn,
            self.logger,
            exc_info,
            extra={'crash_id': crash_id}
        )
    def process_crash(self, raw_crash, raw_dumps, processed_crash):
        """Take a raw_crash and its associated raw_dumps and return a processed_crash

        If this throws an exception, the crash was not processed correctly.

        """
        # processor_meta_data will be used to ferry "inside information" to
        # transformation rules. Sometimes rules need a bit more extra
        # information about the transformation process itself.
        processor_meta_data = DotDict()
        processor_meta_data.processor_notes = [
            self.config.processor_name, self.__class__.__name__
        ]
        processor_meta_data.quit_check = self.quit_check
        processor_meta_data.processor = self
        processor_meta_data.config = self.config

        if "processor_notes" in processed_crash:
            original_processor_notes = [
                x.strip() for x in processed_crash.processor_notes.split(";")
            ]
            processor_meta_data.processor_notes.append(
                "earlier processing: %s" %
                processed_crash.get("started_datetime", 'Unknown Date'))
        else:
            original_processor_notes = []

        processed_crash.success = False
        processed_crash.started_datetime = utc_now()
        # for backwards compatibility:
        processed_crash.startedDateTime = processed_crash.started_datetime
        processed_crash.signature = 'EMPTY: crash failed to process'

        crash_id = raw_crash['uuid']

        # quit_check calls ought to be scattered around the code to allow
        # the processor to be responsive to requests to shut down.
        self.quit_check()

        start_time = self.logger.info('starting transform for crash: %s',
                                      crash_id)
        processor_meta_data.started_timestamp = start_time

        # Apply rules; if a rule fails, capture the error and continue onward
        for rule in self.rules:
            try:
                rule.act(raw_crash, raw_dumps, processed_crash,
                         processor_meta_data)

            except Exception as exc:
                # If a rule throws an error, capture it and toss it in the
                # processor notes
                raven_client.capture_error(sentry_dsn=self.sentry_dsn,
                                           logger=self.logger,
                                           extra={'crash_id': crash_id})
                # NOTE(willkg): notes are public, so we can't put exception
                # messages in them
                processor_meta_data.processor_notes.append(
                    'rule %s failed: %s' %
                    (rule.__class__.__name__, exc.__class__.__name__))

            self.quit_check()

        # The crash made it through the processor rules with no exceptions
        # raised, call it a success
        processed_crash.success = True

        # The processor notes are in the form of a list.  Join them all
        # together to make a single string
        processor_meta_data.processor_notes.extend(original_processor_notes)
        processed_crash.processor_notes = '; '.join(
            processor_meta_data.processor_notes)
        completed_datetime = utc_now()
        processed_crash.completed_datetime = completed_datetime

        # For backwards compatibility
        processed_crash.completeddatetime = completed_datetime

        self.logger.info("finishing %s transform for crash: %s",
                         'successful' if processed_crash.success else 'failed',
                         crash_id)
        return processed_crash
예제 #5
0
    def process_crash(self, raw_crash, raw_dumps, processed_crash):
        """Take a raw_crash and its associated raw_dumps and return a processed_crash

        If this throws an exception, the crash was not processed correctly.

        """
        # processor_meta_data will be used to ferry "inside information" to
        # transformation rules. Sometimes rules need a bit more extra
        # information about the transformation process itself.
        processor_meta_data = DotDict()
        processor_meta_data.processor_notes = [
            self.config.processor_name,
            self.__class__.__name__
        ]
        processor_meta_data.quit_check = self.quit_check
        processor_meta_data.processor = self
        processor_meta_data.config = self.config

        if "processor_notes" in processed_crash:
            original_processor_notes = [
                x.strip() for x in processed_crash.processor_notes.split(";")
            ]
            processor_meta_data.processor_notes.append(
                "earlier processing: %s" % processed_crash.get(
                    "started_datetime",
                    'Unknown Date'
                )
            )
        else:
            original_processor_notes = []

        processed_crash.success = False
        processed_crash.started_datetime = utc_now()
        # for backwards compatibility:
        processed_crash.startedDateTime = processed_crash.started_datetime
        processed_crash.signature = 'EMPTY: crash failed to process'

        crash_id = raw_crash['uuid']

        # quit_check calls ought to be scattered around the code to allow
        # the processor to be responsive to requests to shut down.
        self.quit_check()

        start_time = self.logger.info('starting transform for crash: %s', crash_id)
        processor_meta_data.started_timestamp = start_time

        # Apply rules; if a rule fails, capture the error and continue onward
        for rule in self.rules:
            try:
                rule.act(raw_crash, raw_dumps, processed_crash, processor_meta_data)

            except Exception as exc:
                # If a rule throws an error, capture it and toss it in the
                # processor notes
                raven_client.capture_error(
                    sentry_dsn=self.sentry_dsn,
                    logger=self.logger,
                    extra={'crash_id': crash_id}
                )
                # NOTE(willkg): notes are public, so we can't put exception
                # messages in them
                processor_meta_data.processor_notes.append(
                    'rule %s failed: %s' % (rule.__class__.__name__, exc.__class__.__name__)
                )

            self.quit_check()

        # The crash made it through the processor rules with no exceptions
        # raised, call it a success
        processed_crash.success = True

        # The processor notes are in the form of a list.  Join them all
        # together to make a single string
        processor_meta_data.processor_notes.extend(original_processor_notes)
        processed_crash.processor_notes = '; '.join(processor_meta_data.processor_notes)
        completed_datetime = utc_now()
        processed_crash.completed_datetime = completed_datetime

        # For backwards compatibility
        processed_crash.completeddatetime = completed_datetime

        self.logger.info(
            "finishing %s transform for crash: %s",
            'successful' if processed_crash.success else 'failed',
            crash_id
        )
        return processed_crash