Merge "Report pipeline queue length on startup to statsd"

This commit is contained in:
Jenkins 2013-08-27 18:19:45 +00:00 committed by Gerrit Code Review
commit 0f5efced1d
2 changed files with 18 additions and 0 deletions

View File

@ -1081,6 +1081,14 @@ class TestScheduler(testtools.TestCase):
self.assertReportedStat(
'zuul.pipeline.gate.org.project.total_changes', value='1|c')
def test_initial_pipeline_gauges(self):
"Test that each pipeline reported its length on start"
pipeline_names = self.sched.layout.pipelines.keys()
self.assertNotEqual(len(pipeline_names), 0)
for name in pipeline_names:
self.assertReportedStat('zuul.pipeline.%s.current_changes' % name,
value='0|g')
def test_duplicate_pipelines(self):
"Test that a change matching multiple pipelines works"

View File

@ -469,6 +469,16 @@ class Scheduler(threading.Thread):
self._setupMerger()
for trigger in self.triggers.values():
trigger.postConfig()
if statsd:
try:
for pipeline in self.layout.pipelines.values():
items = len(pipeline.getAllItems())
# stats.gauges.zuul.pipeline.NAME.current_changes
key = 'zuul.pipeline.%s' % pipeline.name
statsd.gauge(key + '.current_changes', items)
except Exception:
self.log.exception("Exception reporting initial "
"pipeline stats:")
self._reconfigure = False
self.reconfigure_complete_event.set()
finally: