Integrate sentry with the build worker.

This commit is contained in:
Jake Moshenko 2014-05-19 13:50:45 -04:00
parent 569f542c65
commit b8466169ac
2 changed files with 15 additions and 2 deletions

View file

@ -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):

View file

@ -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'