system/corennnnn
Revision | 16e84cc1e1c8e1b02f646226e38cdc091c3f9a1a (tree) |
---|---|
Time | 2016-08-16 06:52:29 |
Author | James Hawkins <jhawkins@goog...> |
Commiter | James Hawkins |
bootstat: Calculate and log the time_since_last_boot metric.
Bug: 28163811
Change-Id: I2e1350531f6a0fc891c270cfdfca6c8ad63f8040
(cherry picked from commit 2d8b3e66c6fd298bc8f4dc4e8205bb469a89a6f8)
@@ -169,7 +169,19 @@ std::string CalculateBootCompletePrefix() { | ||
169 | 169 | void RecordBootComplete() { |
170 | 170 | BootEventRecordStore boot_event_store; |
171 | 171 | BootEventRecordStore::BootEventRecord record; |
172 | + | |
172 | 173 | time_t uptime = bootstat::ParseUptime(); |
174 | + time_t current_time_utc = time(nullptr); | |
175 | + | |
176 | + if (boot_event_store.GetBootEvent("last_boot_time_utc", &record)) { | |
177 | + time_t last_boot_time_utc = record.second; | |
178 | + time_t time_since_last_boot = difftime(current_time_utc, | |
179 | + last_boot_time_utc); | |
180 | + boot_event_store.AddBootEventWithValue("time_since_last_boot", | |
181 | + time_since_last_boot); | |
182 | + } | |
183 | + | |
184 | + boot_event_store.AddBootEventWithValue("last_boot_time_utc", current_time_utc); | |
173 | 185 | |
174 | 186 | // The boot_complete metric has two variants: boot_complete and |
175 | 187 | // ota_boot_complete. The latter signifies that the device is booting after |