From 0af6a8a6f2d20fa602b005a8a868a8e0ae70078d Mon Sep 17 00:00:00 2001 From: Zack Cerza Date: Wed, 21 Aug 2013 10:07:12 -0500 Subject: [PATCH] Beginnings of support for Sentry. --- requirements.txt | 1 + teuthology/run_tasks.py | 8 +++++++- teuthology/sentry.py | 12 ++++++++++++ 3 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 teuthology/sentry.py diff --git a/requirements.txt b/requirements.txt index 8c5b8d0ec5..4bcb1ab2cf 100644 --- a/requirements.txt +++ b/requirements.txt @@ -12,6 +12,7 @@ httplib2 paramiko >= 1.7.7 pexpect requests == 0.14.0 +raven # Test Dependencies # nose >=1.0.0 diff --git a/teuthology/run_tasks.py b/teuthology/run_tasks.py index 8193839a6a..1e61a4c607 100644 --- a/teuthology/run_tasks.py +++ b/teuthology/run_tasks.py @@ -1,5 +1,6 @@ import sys import logging +from teuthology.sentry import get_client as get_sentry_client log = logging.getLogger(__name__) @@ -30,7 +31,12 @@ def run_tasks(tasks, ctx): ctx.summary['success'] = False if 'failure_reason' not in ctx.summary: ctx.summary['failure_reason'] = str(e) - log.exception('Saw exception from tasks') + msg = 'Saw exception from tasks.' + sentry = get_sentry_client(ctx) + if sentry: + exc_id = sentry.captureException() + msg += " Sentry id %s" % exc_id + log.exception(msg) if ctx.config.get('interactive-on-error'): from .task import interactive log.warning('Saw failure, going into interactive mode...') diff --git a/teuthology/sentry.py b/teuthology/sentry.py new file mode 100644 index 0000000000..ce17520ba4 --- /dev/null +++ b/teuthology/sentry.py @@ -0,0 +1,12 @@ +from raven import Client + +client = None + +def get_client(ctx): + if client: + return client + dsn = ctx.teuthology_config.get('sentry_dsn') + if dsn: + client = Client(dsn=dsn) + return client + -- 2.39.5