Merge "bootstat: Calculate and log the time_since_last_boot metric."

am: 1607ea6

* commit '1607ea64cbdeea766c05d033afe0c65ea978b399':
  bootstat: Calculate and log the time_since_last_boot metric.

Change-Id: I643c0847a75e4ba02db17ea5e4c716f6fcc7b28d
This commit is contained in:
James Hawkins 2016-04-15 16:48:43 +00:00 committed by android-build-merger
commit db20ad1222

View file

@ -205,7 +205,19 @@ std::string CalculateBootCompletePrefix() {
void RecordBootComplete() { void RecordBootComplete() {
BootEventRecordStore boot_event_store; BootEventRecordStore boot_event_store;
BootEventRecordStore::BootEventRecord record; BootEventRecordStore::BootEventRecord record;
time_t uptime = bootstat::ParseUptime(); time_t uptime = bootstat::ParseUptime();
time_t current_time_utc = time(nullptr);
if (boot_event_store.GetBootEvent("last_boot_time_utc", &record)) {
time_t last_boot_time_utc = record.second;
time_t time_since_last_boot = difftime(current_time_utc,
last_boot_time_utc);
boot_event_store.AddBootEventWithValue("time_since_last_boot",
time_since_last_boot);
}
boot_event_store.AddBootEventWithValue("last_boot_time_utc", current_time_utc);
// The boot_complete metric has two variants: boot_complete and // The boot_complete metric has two variants: boot_complete and
// ota_boot_complete. The latter signifies that the device is booting after // ota_boot_complete. The latter signifies that the device is booting after