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

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

Issue 1507993003: status_logger: record step data (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/build
Patch Set: Created 5 years 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 | « no previous file | scripts/master/unittests/status_logger_test.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2014 The Chromium Authors. All rights reserved. 1 # Copyright 2014 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 """Log status events to a file on disk or event collection endpoint.""" 5 """Log status events to a file on disk or event collection endpoint."""
6 6
7 7
8 import json 8 import json
9 import logging 9 import logging
10 import logging.handlers 10 import logging.handlers
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 self._configure({'file_logging': False, 179 self._configure({'file_logging': False,
180 'event_logging': False, 180 'event_logging': False,
181 'ts_mon_logging': False}) # Reset to defaults. 181 'ts_mon_logging': False}) # Reset to defaults.
182 182
183 self._last_checked_active = now 183 self._last_checked_active = now
184 return self._active 184 return self._active
185 185
186 186
187 def send_build_result( 187 def send_build_result(
188 self, scheduled, started, finished, builder_name, bot_name, result, 188 self, scheduled, started, finished, builder_name, bot_name, result,
189 project_id=None, subproject_tag=None): 189 project_id=None, subproject_tag=None, steps=None):
190 """Log a build result for ts_mon. 190 """Log a build result for ts_mon.
191 191
192 This allows computing metrics for builds in mastermon. 192 This allows computing metrics for builds in mastermon.
193 """ 193 """
194 d = { 194 d = {
195 'timestamp_ms': finished * 1000, 195 'timestamp_ms': finished * 1000,
196 'builder': builder_name, 196 'builder': builder_name,
197 'slave': bot_name, 197 'slave': bot_name,
198 'result': result.lower(), 198 'result': result.lower(),
199 'duration_s': finished - started, 199 'duration_s': finished - started,
200 'pending_s': started - scheduled, 200 'pending_s': started - scheduled,
201 'total_s': finished - scheduled, 201 'total_s': finished - scheduled,
202 } 202 }
203 if project_id: 203 if project_id:
204 d['project_id'] = project_id 204 d['project_id'] = project_id
205 if subproject_tag: 205 if subproject_tag:
206 d['subproject_tag'] = subproject_tag 206 d['subproject_tag'] = subproject_tag
207 if steps:
208 d['steps'] = steps
Adrian Kuegel 2015/12/08 11:36:08 I am wondering if this will work. I haven't seen a
207 self.ts_mon_logger.info(json.dumps(d)) 209 self.ts_mon_logger.info(json.dumps(d))
208 210
209 def send_build_event(self, timestamp_kind, timestamp, build_event_type, 211 def send_build_event(self, timestamp_kind, timestamp, build_event_type,
210 bot_name, builder_name, build_number, build_scheduled_ts, 212 bot_name, builder_name, build_number, build_scheduled_ts,
211 step_name=None, step_number=None, result=None, 213 step_name=None, step_number=None, result=None,
212 extra_result_code=None): 214 extra_result_code=None):
213 """Log a build/step event for event_mon.""" 215 """Log a build/step event for event_mon."""
214 216
215 if self.active and self._event_logging: 217 if self.active and self._event_logging:
216 # List options to pass to send_monitoring_event, without the --, to save 218 # List options to pass to send_monitoring_event, without the --, to save
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
485 scheduled = source_stamp.changes[0].when 487 scheduled = source_stamp.changes[0].when
486 488
487 properties = build.getProperties() 489 properties = build.getProperties()
488 extra_result_code = properties.getProperty('extra_result_code') 490 extra_result_code = properties.getProperty('extra_result_code')
489 self.send_build_event( 491 self.send_build_event(
490 'END', finished * 1000, 'BUILD', bot, builderName, build_number, 492 'END', finished * 1000, 'BUILD', bot, builderName, build_number,
491 self._get_requested_at_millis(build), 493 self._get_requested_at_millis(build),
492 result=buildbot.status.results.Results[results], 494 result=buildbot.status.results.Results[results],
493 extra_result_code=extra_result_code) 495 extra_result_code=extra_result_code)
494 496
497 steps_to_send = []
498 for step in build.getSteps():
499 step_started, step_finished = step.getTimes()
500 steps_to_send.append({
501 'step_name': step.getName(),
502 'duration_s': step_finished - step_started,
503 'result': buildbot.status.results.Results[step.getResults()[0]],
504 })
505
495 # If property doesn't exist, this function returns None. 506 # If property doesn't exist, this function returns None.
496 # Note: this is not true for build.getProperty(), it raises KeyError. 507 # Note: this is not true for build.getProperty(), it raises KeyError.
497 project_id = properties.getProperty('patch_project') 508 project_id = properties.getProperty('patch_project')
498 subproject_tag = properties.getProperty('subproject_tag') 509 subproject_tag = properties.getProperty('subproject_tag')
499 self.send_build_result( 510 self.send_build_result(
500 scheduled, started, finished, builderName, bot, 511 scheduled, started, finished, builderName, bot,
501 buildbot.status.results.Results[results], 512 buildbot.status.results.Results[results],
502 project_id, subproject_tag) 513 project_id, subproject_tag, steps=steps_to_send)
503 514
504 def builderRemoved(self, builderName): 515 def builderRemoved(self, builderName):
505 self.log('builderRemoved', '%s', builderName) 516 self.log('builderRemoved', '%s', builderName)
506 517
507 def slaveConnected(self, slaveName): 518 def slaveConnected(self, slaveName):
508 self.log('slaveConnected', '%s', slaveName) 519 self.log('slaveConnected', '%s', slaveName)
509 520
510 def slaveDisconnected(self, slaveName): 521 def slaveDisconnected(self, slaveName):
511 self.log('slaveDisconnected', '%s', slaveName) 522 self.log('slaveDisconnected', '%s', slaveName)
OLDNEW
« no previous file with comments | « no previous file | scripts/master/unittests/status_logger_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698