Add Installer.OSAgeDays metric
This adds a new metric conveying the age of the running OS instance,
where this is defined as the time-span between the current wall-clock
time and the time-stamp of the /etc/lsb-release file. This metric is
reported daily.
BUG=chromium:304950
TEST=New unit tests for daily metrics + unit tests pass. Manual test
for Installer.OSAgeDays by inspecting chrome://histograms.
Change-Id: I6713bed6730641a95443372a3e3166c4e1dc64ee
Reviewed-on: https://chromium-review.googlesource.com/172162
Reviewed-by: Chris Sosa <sosa@chromium.org>
Commit-Queue: David Zeuthen <zeuthen@chromium.org>
Tested-by: David Zeuthen <zeuthen@chromium.org>
diff --git a/update_attempter.h b/update_attempter.h
index b2ee3b0..74b73f6 100644
--- a/update_attempter.h
+++ b/update_attempter.h
@@ -202,11 +202,21 @@
FRIEND_TEST(UpdateAttempterTest, ScheduleErrorEventActionNoEventTest);
FRIEND_TEST(UpdateAttempterTest, ScheduleErrorEventActionTest);
FRIEND_TEST(UpdateAttempterTest, UpdateTest);
+ FRIEND_TEST(UpdateAttempterTest, ReportDailyMetrics);
// Ctor helper method.
void Init(SystemState* system_state,
const std::string& update_completed_marker);
+ // Checks if it's more than 24 hours since daily metrics were last
+ // reported and, if so, reports daily metrics. Returns |true| if
+ // metrics were reported, |false| otherwise.
+ bool CheckAndReportDailyMetrics();
+
+ // Calculates and reports the age of the currently running OS. This
+ // is defined as the age of the /etc/lsb-release file.
+ void ReportOSAge();
+
// Sets the status to the given status and notifies a status update over dbus.
// Also accepts a supplement notice, which is delegated to the scheduler and
// used for making better informed scheduling decisions (e.g. retry timeout).