update_engine: Add metrics to duration to apply an update.
Add new metrics that record the time between an update being seen by the client
to the time when the update is actually applied.
This metric will be recorded only for Enterprise enrolled devices.
UpdateEngine.SuccessfulUpdate.TimeRestrictedDurationFromSeenToUpdateMinutes is
recorded when an update is applied while the
DeviceAutoUpdateTimeRestrictions device policy exists.
UpdateEngine.SuccessfulUpdate.DurationFromSeenToUpdateMinutes is
recorded when an update is applied without the policy.
BUG=chromium:852860
TEST=run updater manually and checked chrome://histograms
Change-Id: I4dd54fc4404ef2e66902113617841808c1f9e616
Reviewed-on: https://chromium-review.googlesource.com/1179230
Commit-Ready: May Lippert <maybelle@chromium.org>
Tested-by: May Lippert <maybelle@chromium.org>
Reviewed-by: Amin Hassani <ahassani@chromium.org>
Reviewed-by: Sen Jiang <senj@chromium.org>
diff --git a/update_attempter.cc b/update_attempter.cc
index 71a4ae1..5cc92e6 100644
--- a/update_attempter.cc
+++ b/update_attempter.cc
@@ -31,6 +31,7 @@
#include <base/rand_util.h>
#include <base/strings/string_util.h>
#include <base/strings/stringprintf.h>
+#include <base/time/time.h>
#include <brillo/bind_lambda.h>
#include <brillo/data_encoding.h>
#include <brillo/errors/error_codes.h>
@@ -982,6 +983,8 @@
if (code == ErrorCode::kSuccess) {
WriteUpdateCompletedMarker();
+ ReportTimeToUpdateAppliedMetric();
+
prefs_->SetInt64(kPrefsDeltaUpdateFailures, 0);
prefs_->SetString(kPrefsPreviousVersion,
omaha_request_params_->app_version());
@@ -1611,4 +1614,26 @@
return false;
}
+void UpdateAttempter::ReportTimeToUpdateAppliedMetric() {
+ const policy::DevicePolicy* device_policy = system_state_->device_policy();
+ if (device_policy && device_policy->IsEnterpriseEnrolled()) {
+ vector<policy::DevicePolicy::WeeklyTimeInterval> parsed_intervals;
+ bool has_time_restrictions =
+ device_policy->GetDisallowedTimeIntervals(&parsed_intervals);
+
+ int64_t update_first_seen_at_int;
+ if (system_state_->prefs()->Exists(kPrefsUpdateFirstSeenAt)) {
+ if (system_state_->prefs()->GetInt64(kPrefsUpdateFirstSeenAt,
+ &update_first_seen_at_int)) {
+ TimeDelta update_delay =
+ system_state_->clock()->GetWallclockTime() -
+ Time::FromInternalValue(update_first_seen_at_int);
+ system_state_->metrics_reporter()
+ ->ReportEnterpriseUpdateSeenToDownloadDays(has_time_restrictions,
+ update_delay.InDays());
+ }
+ }
+ }
+}
+
} // namespace chromeos_update_engine