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

Side by Side 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: CL comments Created 4 years, 5 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 unified diff | Download patch
OLDNEW
(Empty)
1 # Copyright 2016 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
4
5 from buildbot.status.base import StatusReceiverMultiService
6 from twisted.internet import task
7 from twisted.python import log, threadpool
8
9 from infra_libs import ts_mon
10
11
12 class MonitoringStatusReceiver(StatusReceiverMultiService):
13 """Flushes ts_mon metrics once per minute."""
14
15 def __init__(self):
16 StatusReceiverMultiService.__init__(self)
17 self.thread_pool = threadpool.ThreadPool(1, 1)
18 self.loop = task.LoopingCall(self._flush)
19
20 def startService(self):
21 StatusReceiverMultiService.startService(self)
22 self.status = self.parent.getStatus()
23 self.status.subscribe(self)
24
25 self.thread_pool.start()
26 self.loop.start(60, now=False)
agable 2016/06/29 20:17:59 Nice, I like this a lot better than using a change
27
28 def stopService(self):
29 self.loop.stop()
30 self.thread_pool.stop()
31 return StatusReceiverMultiService.stopService(self)
32
33 def _flush(self):
34 self.thread_pool.callInThread(self._flush_and_log_exceptions)
35
36 def _flush_and_log_exceptions(self):
37 try:
38 ts_mon.flush()
39 except Exception:
40 log.err(None, 'Automatic monitoring flush failed.')
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698