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

Side by Side Diff: scripts/master/monitoring_status_receiver.py

Issue 2271123002: Oops - set the master field to an empty string. (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/build.git@master
Patch Set: Oops again Created 4 years, 3 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2016 The Chromium Authors. All rights reserved. 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 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 import collections 5 import collections
6 import time 6 import time
7 7
8 from buildbot.status.base import StatusReceiverMultiService 8 from buildbot.status.base import StatusReceiverMultiService
9 from twisted.internet import defer, reactor, task 9 from twisted.internet import defer, reactor, task
10 from twisted.python import log, threadpool 10 from twisted.python import log, threadpool
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 62
63 @defer.inlineCallbacks 63 @defer.inlineCallbacks
64 def updateMetricsAndFlush(self): 64 def updateMetricsAndFlush(self):
65 try: 65 try:
66 yield self.updateMetrics() 66 yield self.updateMetrics()
67 finally: 67 finally:
68 self.thread_pool.callInThread(self._flush_and_log_exceptions) 68 self.thread_pool.callInThread(self._flush_and_log_exceptions)
69 69
70 @defer.inlineCallbacks 70 @defer.inlineCallbacks
71 def updateMetrics(self): 71 def updateMetrics(self):
72 uptime.set(time.time() - SERVER_STARTED) 72 uptime.set(time.time() - SERVER_STARTED, fields={'master': ''})
73 accepting_builds.set(bool(self.status.master.botmaster.brd.running)) 73 accepting_builds.set(bool(self.status.master.botmaster.brd.running),
74 fields={'master': ''})
74 pool = self.status.master.db.pool 75 pool = self.status.master.db.pool
75 pool_queue.set(pool.q.qsize()) 76 pool_queue.set(pool.q.qsize(), fields={'master': ''})
76 pool_waiting.set(len(pool.waiters)) 77 pool_waiting.set(len(pool.waiters), fields={'master': ''})
77 pool_working.set(len(pool.working)) 78 pool_working.set(len(pool.working), fields={'master': ''})
78 79
79 for builder_name in self.status.getBuilderNames(): 80 for builder_name in self.status.getBuilderNames():
80 fields = {'builder': builder_name} 81 fields = {'builder': builder_name, 'master': ''}
81 builder = self.status.getBuilder(builder_name) 82 builder = self.status.getBuilder(builder_name)
82 slaves = builder.getSlaves() 83 slaves = builder.getSlaves()
83 84
84 connected.set(sum(1 for x in slaves if x.connected), fields=fields) 85 connected.set(sum(1 for x in slaves if x.connected), fields=fields)
85 current_builds.set(len(builder.getCurrentBuilds()), fields=fields) 86 current_builds.set(len(builder.getCurrentBuilds()), fields=fields)
86 state.set(builder.currentBigState, fields=fields) 87 state.set(builder.currentBigState, fields=fields)
87 total.set(len(slaves), fields=fields) 88 total.set(len(slaves), fields=fields)
88 89
89 # Get pending build requests directly from the db for all builders at 90 # Get pending build requests directly from the db for all builders at
90 # once. 91 # once.
91 d = self.status.master.db.buildrequests.getBuildRequests(claimed=False) 92 d = self.status.master.db.buildrequests.getBuildRequests(claimed=False)
92 93
93 # Timeout the database request after 5 seconds. 94 # Timeout the database request after 5 seconds.
94 def timeout(): 95 def timeout():
95 if not d.called: 96 if not d.called:
96 d.cancel() 97 d.cancel()
97 reactor.callLater(5, timeout) 98 reactor.callLater(5, timeout)
98 99
99 try: 100 try:
100 brdicts = yield d 101 brdicts = yield d
101 except Exception as ex: 102 except Exception as ex:
102 log.err(ex, 'getBuildRequests failed while failed populating metrics') 103 log.err(ex, 'getBuildRequests failed while failed populating metrics')
103 else: 104 else:
104 pending_per_builder = collections.defaultdict(int) 105 pending_per_builder = collections.defaultdict(int)
105 for brdict in brdicts: 106 for brdict in brdicts:
106 pending_per_builder[brdict['buildername']] += 1 107 pending_per_builder[brdict['buildername']] += 1
107 108
108 for builder_name, count in pending_per_builder.iteritems(): 109 for builder_name, count in pending_per_builder.iteritems():
109 pending_builds.set(count, fields={'builder': builder_name}) 110 pending_builds.set(count,
111 fields={'builder': builder_name, 'master': ''})
110 112
111 def _flush_and_log_exceptions(self): 113 def _flush_and_log_exceptions(self):
112 try: 114 try:
113 ts_mon.flush() 115 ts_mon.flush()
114 except Exception: 116 except Exception:
115 log.err(None, 'Automatic monitoring flush failed.') 117 log.err(None, 'Automatic monitoring flush failed.')
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698