Report duration uptime for successful update.
We have metrics for attempt duration, attempt duration uptime and
successful update duration, but not successful update duration uptime,
the existing code already keeps track of this metric, it's just not
being reported, this CL added the last missing piece to report this
metric.
Bug: 77884453
Test: check reported metrics in log
Change-Id: I41d703add2199f54cc6eeb7d92f0d52fc36d9a46
diff --git a/metrics_reporter_android.cc b/metrics_reporter_android.cc
index 3cb356f..a5877cb 100644
--- a/metrics_reporter_android.cc
+++ b/metrics_reporter_android.cc
@@ -120,6 +120,7 @@
int64_t num_bytes_downloaded[kNumDownloadSources],
int download_overhead_percentage,
base::TimeDelta total_duration,
+ base::TimeDelta /* total_duration_uptime */,
int reboot_count,
int /* url_switch_count */) {
LogHistogram(metrics::kMetricsUpdateEngineSuccessfulUpdateAttemptCount,
diff --git a/metrics_reporter_android.h b/metrics_reporter_android.h
index ee94e43..a33e6f9 100644
--- a/metrics_reporter_android.h
+++ b/metrics_reporter_android.h
@@ -67,6 +67,7 @@
int64_t num_bytes_downloaded[kNumDownloadSources],
int download_overhead_percentage,
base::TimeDelta total_duration,
+ base::TimeDelta total_duration_uptime,
int reboot_count,
int url_switch_count) override;
diff --git a/metrics_reporter_interface.h b/metrics_reporter_interface.h
index 2c7ce5b..e96ac1e 100644
--- a/metrics_reporter_interface.h
+++ b/metrics_reporter_interface.h
@@ -150,6 +150,7 @@
// |kMetricSuccessfulUpdateDownloadSourcesUsed|
// |kMetricSuccessfulUpdateDownloadOverheadPercentage|
// |kMetricSuccessfulUpdateTotalDurationMinutes|
+ // |kMetricSuccessfulUpdateTotalDurationUptimeMinutes|
// |kMetricSuccessfulUpdateRebootCount|
// |kMetricSuccessfulUpdateUrlSwitchCount|
//
@@ -164,6 +165,7 @@
int64_t num_bytes_downloaded[kNumDownloadSources],
int download_overhead_percentage,
base::TimeDelta total_duration,
+ base::TimeDelta total_duration_uptime,
int reboot_count,
int url_switch_count) = 0;
diff --git a/metrics_reporter_omaha.cc b/metrics_reporter_omaha.cc
index 0397b83..df3e4d4 100644
--- a/metrics_reporter_omaha.cc
+++ b/metrics_reporter_omaha.cc
@@ -92,6 +92,8 @@
"UpdateEngine.SuccessfulUpdate.RebootCount";
const char kMetricSuccessfulUpdateTotalDurationMinutes[] =
"UpdateEngine.SuccessfulUpdate.TotalDurationMinutes";
+const char kMetricSuccessfulUpdateTotalDurationUptimeMinutes[] =
+ "UpdateEngine.SuccessfulUpdate.TotalDurationUptimeMinutes";
const char kMetricSuccessfulUpdateUpdatesAbandonedCount[] =
"UpdateEngine.SuccessfulUpdate.UpdatesAbandonedCount";
const char kMetricSuccessfulUpdateUrlSwitchCount[] =
@@ -363,6 +365,7 @@
int64_t num_bytes_downloaded[kNumDownloadSources],
int download_overhead_percentage,
base::TimeDelta total_duration,
+ base::TimeDelta total_duration_uptime,
int reboot_count,
int url_switch_count) {
string metric = metrics::kMetricSuccessfulUpdatePayloadSizeMiB;
@@ -442,6 +445,15 @@
365 * 24 * 60, // max: 365 days ~= 1 year
50); // num_buckets
+ metric = metrics::kMetricSuccessfulUpdateTotalDurationUptimeMinutes;
+ LOG(INFO) << "Uploading " << utils::FormatTimeDelta(total_duration_uptime)
+ << " for metric " << metric;
+ metrics_lib_->SendToUMA(metric,
+ static_cast<int>(total_duration_uptime.InMinutes()),
+ 0, // min: 0 min
+ 30 * 24 * 60, // max: 30 days
+ 50); // num_buckets
+
metric = metrics::kMetricSuccessfulUpdateRebootCount;
LOG(INFO) << "Uploading reboot count of " << reboot_count << " for metric "
<< metric;
diff --git a/metrics_reporter_omaha.h b/metrics_reporter_omaha.h
index c19fe86..5e88923 100644
--- a/metrics_reporter_omaha.h
+++ b/metrics_reporter_omaha.h
@@ -70,6 +70,7 @@
extern const char kMetricSuccessfulUpdatePayloadSizeMiB[];
extern const char kMetricSuccessfulUpdateRebootCount[];
extern const char kMetricSuccessfulUpdateTotalDurationMinutes[];
+extern const char kMetricSuccessfulUpdateTotalDurationUptimeMinutes[];
extern const char kMetricSuccessfulUpdateUpdatesAbandonedCount[];
extern const char kMetricSuccessfulUpdateUrlSwitchCount[];
@@ -131,6 +132,7 @@
int64_t num_bytes_downloaded[kNumDownloadSources],
int download_overhead_percentage,
base::TimeDelta total_duration,
+ base::TimeDelta total_duration_uptime,
int reboot_count,
int url_switch_count) override;
diff --git a/metrics_reporter_omaha_unittest.cc b/metrics_reporter_omaha_unittest.cc
index 76e33c6..2fe5d66 100644
--- a/metrics_reporter_omaha_unittest.cc
+++ b/metrics_reporter_omaha_unittest.cc
@@ -258,6 +258,7 @@
num_bytes_downloaded[0] = 200 * kNumBytesInOneMiB;
int download_overhead_percentage = 20;
TimeDelta total_duration = TimeDelta::FromMinutes(30);
+ TimeDelta total_duration_uptime = TimeDelta::FromMinutes(20);
int reboot_count = 2;
int url_switch_count = 2;
@@ -306,6 +307,14 @@
.Times(1);
EXPECT_CALL(
*mock_metrics_lib_,
+ SendToUMA(metrics::kMetricSuccessfulUpdateTotalDurationUptimeMinutes,
+ 20,
+ _,
+ _,
+ _))
+ .Times(1);
+ EXPECT_CALL(
+ *mock_metrics_lib_,
SendToUMA(
metrics::kMetricSuccessfulUpdateRebootCount, reboot_count, _, _, _))
.Times(1);
@@ -333,6 +342,7 @@
num_bytes_downloaded,
download_overhead_percentage,
total_duration,
+ total_duration_uptime,
reboot_count,
url_switch_count);
}
diff --git a/metrics_reporter_stub.h b/metrics_reporter_stub.h
index d0f75ab..6ffd05c 100644
--- a/metrics_reporter_stub.h
+++ b/metrics_reporter_stub.h
@@ -67,6 +67,7 @@
int64_t num_bytes_downloaded[kNumDownloadSources],
int download_overhead_percentage,
base::TimeDelta total_duration,
+ base::TimeDelta total_duration_uptime,
int reboot_count,
int url_switch_count) override {}
diff --git a/mock_metrics_reporter.h b/mock_metrics_reporter.h
index c35a105..3d39049 100644
--- a/mock_metrics_reporter.h
+++ b/mock_metrics_reporter.h
@@ -56,16 +56,17 @@
MOCK_METHOD0(ReportAbnormallyTerminatedUpdateAttemptMetrics, void());
- MOCK_METHOD9(ReportSuccessfulUpdateMetrics,
- void(int attempt_count,
- int updates_abandoned_count,
- PayloadType payload_type,
- int64_t payload_size,
- int64_t num_bytes_downloaded[kNumDownloadSources],
- int download_overhead_percentage,
- base::TimeDelta total_duration,
- int reboot_count,
- int url_switch_count));
+ MOCK_METHOD10(ReportSuccessfulUpdateMetrics,
+ void(int attempt_count,
+ int updates_abandoned_count,
+ PayloadType payload_type,
+ int64_t payload_size,
+ int64_t num_bytes_downloaded[kNumDownloadSources],
+ int download_overhead_percentage,
+ base::TimeDelta total_duration,
+ base::TimeDelta total_duration_uptime,
+ int reboot_count,
+ int url_switch_count));
MOCK_METHOD2(ReportCertificateCheckMetrics,
void(ServerToCheck server_to_check,
diff --git a/payload_state.cc b/payload_state.cc
index 48cbb05..b0e949b 100644
--- a/payload_state.cc
+++ b/payload_state.cc
@@ -729,6 +729,7 @@
SetNumReboots(0);
TimeDelta duration = GetUpdateDuration();
+ TimeDelta duration_uptime = GetUpdateDurationUptime();
prefs_->Delete(kPrefsUpdateTimestampStart);
prefs_->Delete(kPrefsUpdateDurationUptime);
@@ -749,6 +750,7 @@
total_bytes_by_source,
download_overhead_percentage,
duration,
+ duration_uptime,
reboot_count,
url_switch_count);
}
diff --git a/payload_state_unittest.cc b/payload_state_unittest.cc
index f71a8c1..52c28d0 100644
--- a/payload_state_unittest.cc
+++ b/payload_state_unittest.cc
@@ -871,7 +871,7 @@
EXPECT_CALL(*fake_system_state.mock_metrics_reporter(),
ReportSuccessfulUpdateMetrics(
- 1, _, kPayloadTypeFull, _, _, 314, _, _, 3));
+ 1, _, kPayloadTypeFull, _, _, 314, _, _, _, 3));
payload_state.UpdateSucceeded();
@@ -920,6 +920,7 @@
_,
_,
_,
+ _,
_))
.Times(1);
@@ -1305,9 +1306,9 @@
// Simulate a successful download and update.
payload_state.DownloadComplete();
- EXPECT_CALL(
- *fake_system_state.mock_metrics_reporter(),
- ReportSuccessfulUpdateMetrics(_, _, kPayloadTypeDelta, _, _, _, _, _, _));
+ EXPECT_CALL(*fake_system_state.mock_metrics_reporter(),
+ ReportSuccessfulUpdateMetrics(
+ _, _, kPayloadTypeDelta, _, _, _, _, _, _, _));
payload_state.UpdateSucceeded();
// Mock the request to a request where the delta was disabled but Omaha sends
@@ -1321,9 +1322,9 @@
payload_state.DownloadComplete();
- EXPECT_CALL(
- *fake_system_state.mock_metrics_reporter(),
- ReportSuccessfulUpdateMetrics(_, _, kPayloadTypeDelta, _, _, _, _, _, _));
+ EXPECT_CALL(*fake_system_state.mock_metrics_reporter(),
+ ReportSuccessfulUpdateMetrics(
+ _, _, kPayloadTypeDelta, _, _, _, _, _, _, _));
payload_state.UpdateSucceeded();
}
@@ -1346,7 +1347,7 @@
EXPECT_CALL(*fake_system_state.mock_metrics_reporter(),
ReportSuccessfulUpdateMetrics(
- _, _, kPayloadTypeForcedFull, _, _, _, _, _, _));
+ _, _, kPayloadTypeForcedFull, _, _, _, _, _, _, _));
payload_state.UpdateSucceeded();
}
@@ -1368,9 +1369,9 @@
// Simulate a successful download and update.
payload_state.DownloadComplete();
- EXPECT_CALL(
- *fake_system_state.mock_metrics_reporter(),
- ReportSuccessfulUpdateMetrics(_, _, kPayloadTypeFull, _, _, _, _, _, _));
+ EXPECT_CALL(*fake_system_state.mock_metrics_reporter(),
+ ReportSuccessfulUpdateMetrics(
+ _, _, kPayloadTypeFull, _, _, _, _, _, _, _));
payload_state.UpdateSucceeded();
}
diff --git a/update_attempter_android.cc b/update_attempter_android.cc
index 3ca8db7..2f842ac 100644
--- a/update_attempter_android.cc
+++ b/update_attempter_android.cc
@@ -748,6 +748,7 @@
num_bytes_downloaded,
download_overhead_percentage,
duration,
+ duration_uptime,
static_cast<int>(reboot_count),
0); // url_switch_count
}
diff --git a/update_attempter_android_unittest.cc b/update_attempter_android_unittest.cc
index 7d0daec..6b53a21 100644
--- a/update_attempter_android_unittest.cc
+++ b/update_attempter_android_unittest.cc
@@ -140,7 +140,8 @@
ErrorCode::kSuccess))
.Times(1);
EXPECT_CALL(*metrics_reporter_,
- ReportSuccessfulUpdateMetrics(2, 0, _, _, _, _, duration, 3, _))
+ ReportSuccessfulUpdateMetrics(
+ 2, 0, _, _, _, _, duration, duration_uptime, 3, _))
.Times(1);
SetUpdateStatus(UpdateStatus::UPDATE_AVAILABLE);
@@ -181,6 +182,7 @@
125,
_,
_,
+ _,
_))
.Times(1);