Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(788)

Unified Diff: scripts/master/monitoring_status_receiver.py

Issue 2103073002: Make Buildbot masters send ts_mon metrics, and add standard HTTP server metrics. (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/build.git@buildbot-tsmon
Patch Set: Oops Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « scripts/master/master_utils.py ('k') | third_party/buildbot_8_4p1/buildbot/status/web/baseweb.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: scripts/master/monitoring_status_receiver.py
diff --git a/scripts/master/monitoring_status_receiver.py b/scripts/master/monitoring_status_receiver.py
new file mode 100644
index 0000000000000000000000000000000000000000..db096b93ab8e38ca9e3afe077d6474b7e52d3d87
--- /dev/null
+++ b/scripts/master/monitoring_status_receiver.py
@@ -0,0 +1,41 @@
+# Copyright 2016 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+from buildbot.status.base import StatusReceiverMultiService
+from twisted.internet import task
+from twisted.python import log, threadpool
+
+from infra_libs import ts_mon
+
+
+class MonitoringStatusReceiver(StatusReceiverMultiService):
+ """Flushes ts_mon metrics once per minute."""
+
+ def __init__(self):
+ StatusReceiverMultiService.__init__(self)
+ self.status = None
+ self.thread_pool = threadpool.ThreadPool(1, 1)
+ self.loop = task.LoopingCall(self._flush)
+
+ def startService(self):
+ StatusReceiverMultiService.startService(self)
+ self.status = self.parent.getStatus()
+ self.status.subscribe(self)
+
+ self.thread_pool.start()
+ self.loop.start(60, now=False)
+
+ def stopService(self):
+ self.loop.stop()
+ self.thread_pool.stop()
+ return StatusReceiverMultiService.stopService(self)
+
+ def _flush(self):
+ self.thread_pool.callInThread(self._flush_and_log_exceptions)
+
+ def _flush_and_log_exceptions(self):
+ try:
+ ts_mon.flush()
+ except Exception:
+ log.err(None, 'Automatic monitoring flush failed.')
« no previous file with comments | « scripts/master/master_utils.py ('k') | third_party/buildbot_8_4p1/buildbot/status/web/baseweb.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698