| OLD | NEW |
| 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 476 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 487 scheduled = source_stamp.changes[0].when | 487 scheduled = source_stamp.changes[0].when |
| 488 | 488 |
| 489 properties = build.getProperties() | 489 properties = build.getProperties() |
| 490 extra_result_code = properties.getProperty('extra_result_code') | 490 extra_result_code = properties.getProperty('extra_result_code') |
| 491 self.send_build_event( | 491 self.send_build_event( |
| 492 'END', finished * 1000, 'BUILD', bot, builderName, build_number, | 492 'END', finished * 1000, 'BUILD', bot, builderName, build_number, |
| 493 self._get_requested_at_millis(build), | 493 self._get_requested_at_millis(build), |
| 494 result=buildbot.status.results.Results[results], | 494 result=buildbot.status.results.Results[results], |
| 495 extra_result_code=extra_result_code) | 495 extra_result_code=extra_result_code) |
| 496 | 496 |
| 497 # It's important that the recipe does not generate unbounded number |
| 498 # of step names (e.g. one for each git revision), to avoid stream |
| 499 # explosion in the monitoring system. Another alternative is for the recipe |
| 500 # to clearly mark such dynamic steps - e.g. add "(dynamic)" to the name, |
| 501 # and exclude such steps here. |
| 502 WHITELISTED_RECIPES = [ |
| 503 'chromium_trybot', |
| 504 ] |
| 497 steps_to_send = [] | 505 steps_to_send = [] |
| 498 for step in build.getSteps(): | 506 if properties.getProperty('recipe') in WHITELISTED_RECIPES: |
| 499 step_started, step_finished = step.getTimes() | 507 for step in build.getSteps(): |
| 500 steps_to_send.append({ | 508 step_started, step_finished = step.getTimes() |
| 501 'step_name': step.getName(), | 509 steps_to_send.append({ |
| 502 'duration_s': step_finished - step_started, | 510 'step_name': step.getName(), |
| 503 'result': buildbot.status.results.Results[step.getResults()[0]], | 511 'duration_s': step_finished - step_started, |
| 504 }) | 512 'result': buildbot.status.results.Results[step.getResults()[0]], |
| 513 }) |
| 505 | 514 |
| 506 # If property doesn't exist, this function returns None. | 515 # If property doesn't exist, this function returns None. |
| 507 # Note: this is not true for build.getProperty(), it raises KeyError. | 516 # Note: this is not true for build.getProperty(), it raises KeyError. |
| 508 project_id = properties.getProperty('patch_project') | 517 project_id = properties.getProperty('patch_project') |
| 509 subproject_tag = properties.getProperty('subproject_tag') | 518 subproject_tag = properties.getProperty('subproject_tag') |
| 510 self.send_build_result( | 519 self.send_build_result( |
| 511 scheduled, started, finished, builderName, bot, | 520 scheduled, started, finished, builderName, bot, |
| 512 buildbot.status.results.Results[results], | 521 buildbot.status.results.Results[results], |
| 513 project_id, subproject_tag, steps=steps_to_send) | 522 project_id, subproject_tag, steps=steps_to_send) |
| 514 | 523 |
| 515 def builderRemoved(self, builderName): | 524 def builderRemoved(self, builderName): |
| 516 self.log('builderRemoved', '%s', builderName) | 525 self.log('builderRemoved', '%s', builderName) |
| 517 | 526 |
| 518 def slaveConnected(self, slaveName): | 527 def slaveConnected(self, slaveName): |
| 519 self.log('slaveConnected', '%s', slaveName) | 528 self.log('slaveConnected', '%s', slaveName) |
| 520 | 529 |
| 521 def slaveDisconnected(self, slaveName): | 530 def slaveDisconnected(self, slaveName): |
| 522 self.log('slaveDisconnected', '%s', slaveName) | 531 self.log('slaveDisconnected', '%s', slaveName) |
| OLD | NEW |