From b8466169ac5cdd3c260fe36d2b1c85d384295a7a Mon Sep 17 00:00:00 2001 From: Jake Moshenko Date: Mon, 19 May 2014 13:50:45 -0400 Subject: [PATCH] Integrate sentry with the build worker. --- util/exceptionlog.py | 10 +++++++++- workers/dockerfilebuild.py | 7 ++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/util/exceptionlog.py b/util/exceptionlog.py index 462e3229b..b95ca6822 100644 --- a/util/exceptionlog.py +++ b/util/exceptionlog.py @@ -1,7 +1,15 @@ from raven.contrib.flask import Sentry as FlaskSentry +class FakeSentryClient(object): + def captureException(self, *args, **kwargs): + pass + + def user_context(self, *args, **kwargs): + pass + class FakeSentry(object): - pass + def __init__(self): + self.client = FakeSentryClient() class Sentry(object): def __init__(self, app=None): diff --git a/workers/dockerfilebuild.py b/workers/dockerfilebuild.py index 084905e91..dbd9ab3a4 100644 --- a/workers/dockerfilebuild.py +++ b/workers/dockerfilebuild.py @@ -21,7 +21,7 @@ from collections import defaultdict from data.queue import dockerfile_build_queue from data import model from workers.worker import Worker, WorkerUnhealthyException, JobException -from app import userfiles as user_files, build_logs +from app import userfiles as user_files, build_logs, sentry from util.safetar import safe_extractall from util.dockerfileparse import parse_dockerfile, ParsedDockerfile, serialize_dockerfile @@ -141,6 +141,7 @@ class DockerfileBuildContext(object): self.__cleanup_images() self.__prune_cache() except APIError: + sentry.client.captureException() message = 'Docker installation is no longer healthy.' logger.exception(message) raise WorkerUnhealthyException(message) @@ -450,6 +451,9 @@ class DockerfileBuildWorker(Worker): def process_queue_item(self, job_details): self._timeout.clear() + # Make sure we have more information for debugging problems + sentry.client.user_context(job_details) + repository_build = model.get_repository_build(job_details['namespace'], job_details['repository'], job_details['build_uuid']) @@ -540,6 +544,7 @@ class DockerfileBuildWorker(Worker): raise exc except Exception as exc: + sentry.client.captureException() log_appender('error', build_logs.PHASE) logger.exception('Exception when processing request.') repository_build.phase = 'error'