]> git-server-git.apps.pok.os.sepia.ceph.com Git - teuthology.git/commitdiff
exceptions: group CommandFailedErrors in sentry more finely 1593/head
authorJosh Durgin <jdurgin@redhat.com>
Mon, 4 Jan 2021 15:43:54 +0000 (10:43 -0500)
committerJosh Durgin <jdurgin@redhat.com>
Wed, 6 Jan 2021 03:00:14 +0000 (22:00 -0500)
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 <jdurgin@redhat.com>
teuthology/exceptions.py
teuthology/run_tasks.py

index 7a29b11837b82639ecaf926dd35ae11b14f051bd..71f33e7622e19b3018af2415f6cbc08151a39547 100644 (file)
@@ -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):
 
index c8d36fdb8a6e195e283418f946832a07a15fb2af..602559f7fb2c75e37a711e8e784ed85ca1ab02ea 100644 (file)
@@ -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)