Be more cautious with stats calculations.
These occur at critical points in the code and should be protected with exception handlers. Make sure that a build actually has a start time before calculating its duration. Change-Id: I1ff1260da0b7b5095c6b075bd0d78c7a1490686a Reviewed-on: https://review.openstack.org/19023 Reviewed-by: Jeremy Stanley <fungi@yuggoth.org> Reviewed-by: Clark Boylan <clark.boylan@gmail.com> Approved: James E. Blair <corvus@inaugust.com> Tested-by: Jenkins
This commit is contained in:
parent
f62d428f3b
commit
23ec1bac6b
|
@ -218,8 +218,11 @@ class Scheduler(threading.Thread):
|
|||
|
||||
def addEvent(self, event):
|
||||
self.log.debug("Adding trigger event: %s" % event)
|
||||
if statsd:
|
||||
statsd.incr('gerrit.event.%s' % event.type)
|
||||
try:
|
||||
if statsd:
|
||||
statsd.incr('gerrit.event.%s' % event.type)
|
||||
except:
|
||||
self.log.exception("Exception reporting event stats")
|
||||
self.queue_lock.acquire()
|
||||
self.trigger_event_queue.put(event)
|
||||
self.queue_lock.release()
|
||||
|
@ -238,12 +241,15 @@ class Scheduler(threading.Thread):
|
|||
def onBuildCompleted(self, build):
|
||||
self.log.debug("Adding complete event for build: %s" % build)
|
||||
build.end_time = time.time()
|
||||
if statsd:
|
||||
key = 'zuul.job.%s' % build.job.name
|
||||
if build.result in ['SUCCESS', 'FAILURE']:
|
||||
dt = int((build.end_time - build.start_time) * 1000)
|
||||
statsd.timing(key, dt)
|
||||
statsd.incr(key)
|
||||
try:
|
||||
if statsd:
|
||||
key = 'zuul.job.%s' % build.job.name
|
||||
if build.result in ['SUCCESS', 'FAILURE'] and build.start_time:
|
||||
dt = int((build.end_time - build.start_time) * 1000)
|
||||
statsd.timing(key, dt)
|
||||
statsd.incr(key)
|
||||
except:
|
||||
self.log.exception("Exception reporting runtime stats")
|
||||
self.queue_lock.acquire()
|
||||
self.result_event_queue.put(('completed', build))
|
||||
self.queue_lock.release()
|
||||
|
|
Loading…
Reference in New Issue