Fix two android metrics reporting in update engine
1. The AttemptCurrentBytesDownloadedMiB was reported in bytes.
2. We were using the same start timestamp (in monotonic_time) for both
boot_time and monotonic_time. This leads to an inaccurate update
duration reporting. This cl saves an extra perf for the boot time and
calculates the duration accordingly.
Also report these information with a different metrics name.
Bug: 30989466
Test: Run an update and check the report
Change-Id: I69e20648501a736a59ff60ca9202ce7bdd9b6e34
diff --git a/update_attempter_android.cc b/update_attempter_android.cc
index 9443869..4d21de6 100644
--- a/update_attempter_android.cc
+++ b/update_attempter_android.cc
@@ -669,10 +669,12 @@
metrics::AttemptResult attempt_result =
metrics_utils::GetAttemptResult(error_code);
- Time attempt_start_time = Time::FromInternalValue(
+ Time boot_time_start = Time::FromInternalValue(
+ metrics_utils::GetPersistedValue(kPrefsUpdateBootTimestampStart, prefs_));
+ Time monotonic_time_start = Time::FromInternalValue(
metrics_utils::GetPersistedValue(kPrefsUpdateTimestampStart, prefs_));
- TimeDelta duration = clock_->GetBootTime() - attempt_start_time;
- TimeDelta duration_uptime = clock_->GetMonotonicTime() - attempt_start_time;
+ TimeDelta duration = clock_->GetBootTime() - boot_time_start;
+ TimeDelta duration_uptime = clock_->GetMonotonicTime() - monotonic_time_start;
metrics_reporter_->ReportUpdateAttemptMetrics(
nullptr, // system_state
@@ -791,8 +793,8 @@
metrics_utils::GetPersistedValue(kPrefsPayloadAttemptNumber, prefs_);
metrics_utils::SetPayloadAttemptNumber(attempt_number + 1, prefs_);
}
- Time update_start_time = clock_->GetMonotonicTime();
- metrics_utils::SetUpdateTimestampStart(update_start_time, prefs_);
+ metrics_utils::SetUpdateTimestampStart(clock_->GetMonotonicTime(), prefs_);
+ metrics_utils::SetUpdateBootTimestampStart(clock_->GetBootTime(), prefs_);
}
void UpdateAttempterAndroid::ClearMetricsPrefs() {
@@ -802,6 +804,7 @@
prefs_->Delete(kPrefsPayloadAttemptNumber);
prefs_->Delete(kPrefsSystemUpdatedMarker);
prefs_->Delete(kPrefsUpdateTimestampStart);
+ prefs_->Delete(kPrefsUpdateBootTimestampStart);
}
} // namespace chromeos_update_engine