Browse Source

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
changes/55/609355/1
Simon Westphahl 3 years ago
parent
commit
4d0979664a
  1. 2
      tests/unit/test_connection.py
  2. 3
      zuul/driver/mqtt/mqttreporter.py

2
tests/unit/test_connection.py

@ -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(

3
zuul/driver/mqtt/mqttreporter.py

@ -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': []

Loading…
Cancel
Save