From: Josh Durgin Date: Mon, 4 Jan 2021 15:43:54 +0000 (-0500) Subject: exceptions: group CommandFailedErrors in sentry more finely X-Git-Tag: 1.1.0~23^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F1593%2Fhead;p=teuthology.git exceptions: group CommandFailedErrors in sentry more finely By default sentry uses the stack trace / error type / rough error message, which ends up with many failures from different workunits grouped together. Include the actual command run, the exit status, and the optional label to group these more accurately. This will group failures of the same workunit together, for example. Signed-off-by: Josh Durgin --- diff --git a/teuthology/exceptions.py b/teuthology/exceptions.py index 7a29b118..71f33e76 100644 --- a/teuthology/exceptions.py +++ b/teuthology/exceptions.py @@ -68,6 +68,18 @@ class CommandFailedError(Exception): prefix=prefix, ) + def fingerprint(self): + """ + Returns a list of strings to group failures with. + Used by sentry instead of grouping by backtrace. + """ + return [ + ' '.join(self.command), + 'exit status {}'.format(self.exitstatus), + self.label, + '{{ type }}', + ] + class AnsibleFailedError(Exception): diff --git a/teuthology/run_tasks.py b/teuthology/run_tasks.py index c8d36fdb..602559f7 100644 --- a/teuthology/run_tasks.py +++ b/teuthology/run_tasks.py @@ -131,10 +131,12 @@ def run_tasks(tasks, ctx): if job_id: extras['logs'] = get_http_log_path(archive_path, job_id) + fingerprint = e.fingerprint() if hasattr(e, 'fingerprint') else None exc_id = sentry_sdk.capture_exception( error=e, tags=tags, extras=extras, + fingerprint=fingerprint, ) event_url = "{server}/?query={id}".format( server=teuth_config.sentry_server.strip('/'), id=exc_id)