Bug 709229: Turn off per-step messages to pulse. r=bear
authorChris AtLee <catlee@mozilla.com>
Fri, 09 Dec 2011 14:37:01 -0500
changeset 2024 90eb7fa4ca891d642a252b27b7cd3caae2c84826
parent 2023 387d4862f3c4eca8259f0711b3710449f6acf921
child 2025 f5e323d6be60ed584ed5335685102fae5890b82c
push id1430
push usercatlee@mozilla.com
push dateFri, 09 Dec 2011 19:37:15 +0000
reviewersbear
bugs709229
Bug 709229: Turn off per-step messages to pulse. r=bear
buildbot-helpers/pulse_publisher.py
--- a/buildbot-helpers/pulse_publisher.py
+++ b/buildbot-helpers/pulse_publisher.py
@@ -4,28 +4,34 @@ Publisher for Pulse events.
 
 Consumes new events being written into a queue directory by the PulseStatus
 plugin
 
 see http://hg.mozilla.org/users/clegnitto_mozilla.com/mozillapulse/ for pulse
 code
 """
 import time
+import re
 from datetime import tzinfo, timedelta, datetime
 
 from mozillapulse.messages.build import BuildMessage
 from mozilla_buildtools.queuedir import QueueDir
 from buildbot.util import json
 
 import logging
 log = logging.getLogger(__name__)
 
 ZERO = timedelta(0)
 HOUR = timedelta(hours=1)
 
+skip_exps = [
+    # Skip step events, they cause too much load
+    re.compile("^build\.\S+\.\d+\.step\."),
+    ]
+
 # A UTC class.
 class UTC(tzinfo):
     """UTC"""
 
     def utcoffset(self, dt):
         return ZERO
 
     def tzname(self, dt):
@@ -99,21 +105,31 @@ class PulsePusher(object):
         Send events to pulse
 
         `events` - a list of buildbot event dicts
         """
         if not self._last_connection and self.max_connect_time:
             self._last_connection = time.time()
         log.debug("Sending %i messages", len(events))
         start = time.time()
+        skipped = 0
+        sent =  0
         for e in events:
+            routing_key = e['event']
+            if any(exp.search(routing_key) for exp in skip_exps):
+                skipped += 1
+                log.debug("Skipping event %s", routing_key)
+                continue
+            else:
+                log.debug("Sending event %s", routing_key)
             msg = BuildMessage(transform_times(e))
             self.publisher.publish(msg)
+            sent += 1
         end = time.time()
-        log.info("Sent %i messages in %.2fs", len(events), end-start)
+        log.info("Sent %i messages in %.2fs (skipped %i)", sent, end-start, skipped)
         self._last_activity = time.time()
 
         # Update our timers
         t = 0
         if self.max_connect_time:
             t = self._last_connection + self.max_connect_time
         if self.max_idle_time:
             if t: