Include enqueue and report timestamps in MQTT msg

Having the enqueue and report timestamp allows for better reporting
regarding the livecycle of a change.

Change-Id: Ia3915ea35853f007181d5660c361417175c29507
This commit is contained in:
Simon Westphahl 2018-10-10 13:23:20 +02:00
parent 8d73978d71
commit 4d0979664a
2 changed files with 5 additions and 0 deletions

View File

@ -492,6 +492,8 @@ class TestMQTTConnection(ZuulTestCase):
'test')
self.assertEquals(mqtt_payload['buildset']['builds'][0]['result'],
'SUCCESS')
self.assertIn('timestamp', mqtt_payload)
self.assertIn('enqueue_time', mqtt_payload)
def test_mqtt_invalid_topic(self):
in_repo_conf = textwrap.dedent(

View File

@ -13,6 +13,7 @@
# under the License.
import logging
import time
import voluptuous as v
from zuul.reporter import BaseReporter
@ -28,6 +29,7 @@ class MQTTReporter(BaseReporter):
self.log.debug("Report change %s, params %s" %
(item.change, self.config))
message = {
'timestamp': time.time(),
'action': self._action,
'tenant': item.pipeline.tenant.name,
'zuul_ref': item.current_build_set.ref,
@ -40,6 +42,7 @@ class MQTTReporter(BaseReporter):
'ref': getattr(item.change, 'ref', ''),
'message': self._formatItemReport(
item, with_jobs=False),
'enqueue_time': item.enqueue_time,
'buildset': {
'uuid': item.current_build_set.uuid,
'builds': []