update_engine: Add UMA stats for rollback
Adding the following UMA stats:
- UpdateEngine.Check.TargetVersion: first section of the Chrome OS
target version set by device policy. Sent during update checks if
target version policy is set.
- UpdateEngine.Check.RollbackTargetVersion: first section of the
Chrome OS target version if rollback is also allowed. Sent during
update checks if both policies are set.
- UpdateEngine.EnterpriseRollback.Success: first section of the
Chrome OS version to which rollback succeeded. Sent after
successful installation of the rollback image.
- UpdateEngine.EnterpriseRollback.Failure: first section of the
Chrome OS version to which rollback failed. Sent after
installation of the rollback image failed.
Chromium CL of the new histograms: crrev.com/c/1069129
BUG=chromium:843622
TEST='cros_run_unit_tests --board=caroline --packages update_engine'
Change-Id: I0b76fa286498ae0a1830a90034734ed9aa5efd3d
Reviewed-on: https://chromium-review.googlesource.com/1062033
Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com>
Tested-by: Marton Hunyady <hunyadym@chromium.org>
Reviewed-by: Amin Hassani <ahassani@chromium.org>
Reviewed-by: Jesse Doherty <jwd@chromium.org>
diff --git a/update_attempter.cc b/update_attempter.cc
index 4a71e4d..67391a3 100644
--- a/update_attempter.cc
+++ b/update_attempter.cc
@@ -1007,6 +1007,8 @@
// over the following powerwash.
if (install_plan.is_rollback) {
system_state_->payload_state()->SetRollbackHappened(true);
+ system_state_->metrics_reporter()->ReportEnterpriseRollbackMetrics(
+ /*success=*/true, install_plan.version);
}
// Expect to reboot into the new version to send the proper metric during
@@ -1377,6 +1379,15 @@
LOG(ERROR) << "Update failed.";
system_state_->payload_state()->UpdateFailed(error_event_->error_code);
+ // Send metrics if it was a rollback.
+ if (response_handler_action_) {
+ const InstallPlan& install_plan = response_handler_action_->install_plan();
+ if (install_plan.is_rollback) {
+ system_state_->metrics_reporter()->ReportEnterpriseRollbackMetrics(
+ /*success=*/false, install_plan.version);
+ }
+ }
+
// Send it to Omaha.
LOG(INFO) << "Reporting the error event";
shared_ptr<OmahaRequestAction> error_event_action(