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

Side by Side Diff: third_party/buildbot_8_4p1/buildbot/status/web/status_json.py

Issue 1383143003: Remove deprecated metrics from buildbot /varz. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/build
Patch Set: Created 5 years, 2 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 | Annotate | Revision Log
« no previous file with comments | « third_party/buildbot_8_4p1/README.chromium ('k') | 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 # This file is part of Buildbot. Buildbot is free software: you can 1 # This file is part of Buildbot. Buildbot is free software: you can
2 # redistribute it and/or modify it under the terms of the GNU General Public 2 # redistribute it and/or modify it under the terms of the GNU General Public
3 # License as published by the Free Software Foundation, version 2. 3 # License as published by the Free Software Foundation, version 2.
4 # 4 #
5 # This program is distributed in the hope that it will be useful, but WITHOUT 5 # This program is distributed in the hope that it will be useful, but WITHOUT
6 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 6 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
7 # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 7 # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
8 # details. 8 # details.
9 # 9 #
10 # You should have received a copy of the GNU General Public License along with 10 # You should have received a copy of the GNU General Public License along with
(...skipping 1030 matching lines...) Expand 10 before | Expand all | Expand 10 after
1041 def asDict(self, _request): 1041 def asDict(self, _request):
1042 return { 1042 return {
1043 'accepting_builds': bool(self.status.master.botmaster.brd.running), 1043 'accepting_builds': bool(self.status.master.botmaster.brd.running),
1044 } 1044 }
1045 1045
1046 1046
1047 class VarzResource(JsonResource): 1047 class VarzResource(JsonResource):
1048 help = 'Minimal set of metrics that are scraped frequently for monitoring.' 1048 help = 'Minimal set of metrics that are scraped frequently for monitoring.'
1049 pageTitle = 'Varz' 1049 pageTitle = 'Varz'
1050 1050
1051 RECENT_BUILDS_COUNT_DEFAULT = 50
1052 RECENT_BUILDS_COUNT_LIMIT = 200
1053
1054 @defer.deferredGenerator 1051 @defer.deferredGenerator
1055 def asDict(self, request): 1052 def asDict(self, request):
1056 recent_builds_count = int(RequestArg(
1057 request, 'recent_builds_count', self.RECENT_BUILDS_COUNT_DEFAULT))
1058
1059 # Enforce a hard limit to avoid DoS-ing buildbot with a heavy request.
1060 recent_builds_count = min(
1061 recent_builds_count, self.RECENT_BUILDS_COUNT_LIMIT)
1062
1063 builders = {} 1053 builders = {}
1064 for builder_name in self.status.getBuilderNames(): 1054 for builder_name in self.status.getBuilderNames():
1065 builder = self.status.getBuilder(builder_name) 1055 builder = self.status.getBuilder(builder_name)
1066
1067 build_range = range(-1, -recent_builds_count - 1, -1)
1068 recent_builds = [b for b in builder.getBuilds(build_range)
1069 if b is not None]
1070 recent_running_builds = [b for b in recent_builds
1071 if not b.isFinished()]
1072 recent_finished_builds = [b for b in recent_builds
1073 if b.isFinished()]
1074 recent_successful_builds = [
1075 b for b in recent_finished_builds
1076 if b.getResults() in (SUCCESS, WARNINGS)]
1077
1078 recent_builds_by_status = collections.defaultdict(int)
1079 recent_builds_by_status['running'] = len(recent_running_builds)
1080 for b in recent_finished_builds:
1081 recent_builds_by_status[b.getResults()] += 1
1082
1083 recent_successful_build_times = [
1084 int(b.getTimes()[1] - b.getTimes()[0])
1085 for b in recent_successful_builds]
1086 recent_finished_build_times = [
1087 int(b.getTimes()[1] - b.getTimes()[0])
1088 for b in recent_finished_builds]
1089
1090 slaves = builder.getSlaves() 1056 slaves = builder.getSlaves()
1091 builders[builder_name] = { 1057 builders[builder_name] = {
1092 'connected_slaves': sum(1 for x in slaves if x.connected), 1058 'connected_slaves': sum(1 for x in slaves if x.connected),
1093 'current_builds': len(builder.getCurrentBuilds()), 1059 'current_builds': len(builder.getCurrentBuilds()),
1094 'recent_builds_by_status': recent_builds_by_status,
1095 'recent_successful_build_times': recent_successful_build_times,
1096 'recent_finished_build_times': recent_finished_build_times,
1097 'pending_builds': 0, 1060 'pending_builds': 0,
1098 'state': builder.currentBigState, 1061 'state': builder.currentBigState,
1099 'total_slaves': len(slaves), 1062 'total_slaves': len(slaves),
1100 } 1063 }
1101 1064
1102 # Get pending build requests directly from the db for all builders at 1065 # Get pending build requests directly from the db for all builders at
1103 # once. 1066 # once.
1104 d = self.status.master.db.buildrequests.getBuildRequests(claimed=False) 1067 d = self.status.master.db.buildrequests.getBuildRequests(claimed=False)
1105 def pending_builds_callback(brdicts): 1068 def pending_builds_callback(brdicts):
1106 for brdict in brdicts: 1069 for brdict in brdicts:
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
1161 if not builder: 1124 if not builder:
1162 return 1125 return
1163 EXAMPLES = EXAMPLES.replace('<A_BUILDER>', builder.getName()) 1126 EXAMPLES = EXAMPLES.replace('<A_BUILDER>', builder.getName())
1164 build = builder.getBuild(-1) 1127 build = builder.getBuild(-1)
1165 if build: 1128 if build:
1166 EXAMPLES = EXAMPLES.replace('<A_BUILD>', str(build.getNumber())) 1129 EXAMPLES = EXAMPLES.replace('<A_BUILD>', str(build.getNumber()))
1167 if builder.slavenames: 1130 if builder.slavenames:
1168 EXAMPLES = EXAMPLES.replace('<A_SLAVE>', builder.slavenames[0]) 1131 EXAMPLES = EXAMPLES.replace('<A_SLAVE>', builder.slavenames[0])
1169 1132
1170 # vim: set ts=4 sts=4 sw=4 et: 1133 # vim: set ts=4 sts=4 sw=4 et:
OLDNEW
« no previous file with comments | « third_party/buildbot_8_4p1/README.chromium ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698