Report pipeline queue length on startup to statsd

So that graphs that use a pipeline gauge have some data to work
with, even if it's 0.

Change-Id: Ida46153d8ee27ab212949dc3d417bb4331512de6
This commit is contained in:
James E. Blair 2013-08-24 08:56:03 -07:00
parent 7f4a19088f
commit 3cb1070883
2 changed files with 18 additions and 0 deletions

View File

@ -1070,6 +1070,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

@ -470,6 +470,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: