Log and collect stats for events consistently
Just happened to notice that the scheduler did a statsd call about events with the gerrit name. That's not accurate anymore. Pull that code into the connection so that we can use the driver name and the connection name in the statsd calls and in the log message emitted. Change-Id: Ia5ed9458c0b28573392c576db7789b61f4d87f3b
This commit is contained in:
parent
a457b47589
commit
f138504169
|
@ -64,7 +64,11 @@ class TestScheduler(ZuulTestCase):
|
|||
self.assertIsNone(self.getJobFromHistory('project-test2').node)
|
||||
|
||||
# TODOv3(jeblair): we may want to report stats by tenant (also?).
|
||||
self.assertReportedStat('gerrit.event.comment-added', value='1|c')
|
||||
# Per-driver
|
||||
self.assertReportedStat('zuul.event.gerrit.comment-added', value='1|c')
|
||||
# Per-driver per-connection
|
||||
self.assertReportedStat('zuul.event.gerrit.gerrit.comment-added',
|
||||
value='1|c')
|
||||
self.assertReportedStat('zuul.pipeline.gate.current_changes',
|
||||
value='1|g')
|
||||
self.assertReportedStat('zuul.pipeline.gate.job.project-merge.SUCCESS',
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
|
||||
import abc
|
||||
|
||||
import extras
|
||||
import six
|
||||
|
||||
|
||||
|
@ -43,6 +44,26 @@ class BaseConnection(object):
|
|||
self.driver = driver
|
||||
self.connection_name = connection_name
|
||||
self.connection_config = connection_config
|
||||
self.statsd = extras.try_import('statsd.statsd')
|
||||
|
||||
def logEvent(self, event):
|
||||
self.log.debug(
|
||||
'Scheduling {driver} event from {connection}: {event}'.format(
|
||||
driver=self.driver.name,
|
||||
connection=self.connection_name,
|
||||
event=event.type))
|
||||
try:
|
||||
if self.statsd:
|
||||
self.statsd.incr(
|
||||
'zuul.event.{driver}.{event}'.format(
|
||||
driver=self.driver.name, event=event.type))
|
||||
self.statsd.incr(
|
||||
'zuul.event.{driver}.{connection}.{event}'.format(
|
||||
driver=self.driver.name,
|
||||
connection=self.connection_name,
|
||||
event=event.type))
|
||||
except:
|
||||
self.log.exception("Exception reporting event stats")
|
||||
|
||||
def onLoad(self):
|
||||
pass
|
||||
|
|
|
@ -143,6 +143,7 @@ class GerritEventConnector(threading.Thread):
|
|||
self.connection._getChange(event.change_number,
|
||||
event.patch_number,
|
||||
refresh=True)
|
||||
self.connection.logEvent(event)
|
||||
self.connection.sched.addEvent(event)
|
||||
|
||||
def run(self):
|
||||
|
|
|
@ -72,7 +72,7 @@ class GithubWebhookListener():
|
|||
|
||||
if event:
|
||||
event.project_hostname = self.connection.canonical_hostname
|
||||
self.log.debug('Scheduling github event: {0}'.format(event.type))
|
||||
self.connection.logEvent(event)
|
||||
self.connection.sched.addEvent(event)
|
||||
|
||||
def _event_push(self, request):
|
||||
|
|
|
@ -256,11 +256,6 @@ class Scheduler(threading.Thread):
|
|||
|
||||
def addEvent(self, event):
|
||||
self.log.debug("Adding trigger event: %s" % event)
|
||||
try:
|
||||
if self.statsd:
|
||||
self.statsd.incr('gerrit.event.%s' % event.type)
|
||||
except:
|
||||
self.log.exception("Exception reporting event stats")
|
||||
self.trigger_event_queue.put(event)
|
||||
self.wake_event.set()
|
||||
self.log.debug("Done adding trigger event: %s" % event)
|
||||
|
|
Loading…
Reference in New Issue