Alex Deymo | aea4c1c | 2015-08-19 20:24:43 -0700 | [diff] [blame] | 1 | // |
| 2 | // Copyright (C) 2014 The Android Open Source Project |
| 3 | // |
| 4 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | // you may not use this file except in compliance with the License. |
| 6 | // You may obtain a copy of the License at |
| 7 | // |
| 8 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | // |
| 10 | // Unless required by applicable law or agreed to in writing, software |
| 11 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | // See the License for the specific language governing permissions and |
| 14 | // limitations under the License. |
| 15 | // |
David Zeuthen | 33bae49 | 2014-02-25 16:16:18 -0800 | [diff] [blame] | 16 | |
Tianjie Xu | 282aa1f | 2017-09-05 13:42:45 -0700 | [diff] [blame] | 17 | #include "update_engine/metrics_reporter_omaha.h" |
David Zeuthen | 33bae49 | 2014-02-25 16:16:18 -0800 | [diff] [blame] | 18 | |
Tianjie Xu | 98333a8 | 2017-09-22 21:29:29 -0700 | [diff] [blame] | 19 | #include <memory> |
David Zeuthen | 33bae49 | 2014-02-25 16:16:18 -0800 | [diff] [blame] | 20 | #include <string> |
| 21 | |
| 22 | #include <base/logging.h> |
Alex Deymo | a259179 | 2015-11-17 00:39:40 -0300 | [diff] [blame] | 23 | #include <metrics/metrics_library.h> |
David Zeuthen | 33bae49 | 2014-02-25 16:16:18 -0800 | [diff] [blame] | 24 | |
Alex Deymo | 39910dc | 2015-11-09 17:04:30 -0800 | [diff] [blame] | 25 | #include "update_engine/common/clock_interface.h" |
| 26 | #include "update_engine/common/constants.h" |
| 27 | #include "update_engine/common/prefs_interface.h" |
| 28 | #include "update_engine/common/utils.h" |
Alex Deymo | a259179 | 2015-11-17 00:39:40 -0300 | [diff] [blame] | 29 | #include "update_engine/metrics_utils.h" |
David Zeuthen | 33bae49 | 2014-02-25 16:16:18 -0800 | [diff] [blame] | 30 | #include "update_engine/system_state.h" |
David Zeuthen | 33bae49 | 2014-02-25 16:16:18 -0800 | [diff] [blame] | 31 | |
| 32 | using std::string; |
| 33 | |
| 34 | namespace chromeos_update_engine { |
| 35 | |
Tianjie Xu | 98333a8 | 2017-09-22 21:29:29 -0700 | [diff] [blame] | 36 | namespace metrics { |
| 37 | |
David Zeuthen | 33bae49 | 2014-02-25 16:16:18 -0800 | [diff] [blame] | 38 | // UpdateEngine.Daily.* metrics. |
Tianjie Xu | 98333a8 | 2017-09-22 21:29:29 -0700 | [diff] [blame] | 39 | const char kMetricDailyOSAgeDays[] = "UpdateEngine.Daily.OSAgeDays"; |
David Zeuthen | 33bae49 | 2014-02-25 16:16:18 -0800 | [diff] [blame] | 40 | |
| 41 | // UpdateEngine.Check.* metrics. |
Tianjie Xu | 98333a8 | 2017-09-22 21:29:29 -0700 | [diff] [blame] | 42 | const char kMetricCheckDownloadErrorCode[] = |
David Zeuthen | 33bae49 | 2014-02-25 16:16:18 -0800 | [diff] [blame] | 43 | "UpdateEngine.Check.DownloadErrorCode"; |
Tianjie Xu | 98333a8 | 2017-09-22 21:29:29 -0700 | [diff] [blame] | 44 | const char kMetricCheckReaction[] = "UpdateEngine.Check.Reaction"; |
| 45 | const char kMetricCheckResult[] = "UpdateEngine.Check.Result"; |
| 46 | const char kMetricCheckTimeSinceLastCheckMinutes[] = |
David Zeuthen | 33bae49 | 2014-02-25 16:16:18 -0800 | [diff] [blame] | 47 | "UpdateEngine.Check.TimeSinceLastCheckMinutes"; |
Tianjie Xu | 98333a8 | 2017-09-22 21:29:29 -0700 | [diff] [blame] | 48 | const char kMetricCheckTimeSinceLastCheckUptimeMinutes[] = |
David Zeuthen | 33bae49 | 2014-02-25 16:16:18 -0800 | [diff] [blame] | 49 | "UpdateEngine.Check.TimeSinceLastCheckUptimeMinutes"; |
| 50 | |
| 51 | // UpdateEngine.Attempt.* metrics. |
Tianjie Xu | 98333a8 | 2017-09-22 21:29:29 -0700 | [diff] [blame] | 52 | const char kMetricAttemptNumber[] = "UpdateEngine.Attempt.Number"; |
| 53 | const char kMetricAttemptPayloadType[] = "UpdateEngine.Attempt.PayloadType"; |
| 54 | const char kMetricAttemptPayloadSizeMiB[] = |
David Zeuthen | 33bae49 | 2014-02-25 16:16:18 -0800 | [diff] [blame] | 55 | "UpdateEngine.Attempt.PayloadSizeMiB"; |
Tianjie Xu | 98333a8 | 2017-09-22 21:29:29 -0700 | [diff] [blame] | 56 | const char kMetricAttemptConnectionType[] = |
David Zeuthen | b281f07 | 2014-04-02 10:20:19 -0700 | [diff] [blame] | 57 | "UpdateEngine.Attempt.ConnectionType"; |
Tianjie Xu | 98333a8 | 2017-09-22 21:29:29 -0700 | [diff] [blame] | 58 | const char kMetricAttemptDurationMinutes[] = |
David Zeuthen | 33bae49 | 2014-02-25 16:16:18 -0800 | [diff] [blame] | 59 | "UpdateEngine.Attempt.DurationMinutes"; |
Tianjie Xu | 98333a8 | 2017-09-22 21:29:29 -0700 | [diff] [blame] | 60 | const char kMetricAttemptDurationUptimeMinutes[] = |
David Zeuthen | 33bae49 | 2014-02-25 16:16:18 -0800 | [diff] [blame] | 61 | "UpdateEngine.Attempt.DurationUptimeMinutes"; |
Tianjie Xu | 98333a8 | 2017-09-22 21:29:29 -0700 | [diff] [blame] | 62 | const char kMetricAttemptTimeSinceLastAttemptMinutes[] = |
David Zeuthen | 33bae49 | 2014-02-25 16:16:18 -0800 | [diff] [blame] | 63 | "UpdateEngine.Attempt.TimeSinceLastAttemptMinutes"; |
Tianjie Xu | 98333a8 | 2017-09-22 21:29:29 -0700 | [diff] [blame] | 64 | const char kMetricAttemptTimeSinceLastAttemptUptimeMinutes[] = |
David Zeuthen | 33bae49 | 2014-02-25 16:16:18 -0800 | [diff] [blame] | 65 | "UpdateEngine.Attempt.TimeSinceLastAttemptUptimeMinutes"; |
Tianjie Xu | 98333a8 | 2017-09-22 21:29:29 -0700 | [diff] [blame] | 66 | const char kMetricAttemptPayloadBytesDownloadedMiB[] = |
David Zeuthen | 33bae49 | 2014-02-25 16:16:18 -0800 | [diff] [blame] | 67 | "UpdateEngine.Attempt.PayloadBytesDownloadedMiB"; |
Tianjie Xu | 98333a8 | 2017-09-22 21:29:29 -0700 | [diff] [blame] | 68 | const char kMetricAttemptPayloadDownloadSpeedKBps[] = |
David Zeuthen | 33bae49 | 2014-02-25 16:16:18 -0800 | [diff] [blame] | 69 | "UpdateEngine.Attempt.PayloadDownloadSpeedKBps"; |
Tianjie Xu | 98333a8 | 2017-09-22 21:29:29 -0700 | [diff] [blame] | 70 | const char kMetricAttemptDownloadSource[] = |
David Zeuthen | 33bae49 | 2014-02-25 16:16:18 -0800 | [diff] [blame] | 71 | "UpdateEngine.Attempt.DownloadSource"; |
Tianjie Xu | 98333a8 | 2017-09-22 21:29:29 -0700 | [diff] [blame] | 72 | const char kMetricAttemptResult[] = "UpdateEngine.Attempt.Result"; |
| 73 | const char kMetricAttemptInternalErrorCode[] = |
David Zeuthen | 33bae49 | 2014-02-25 16:16:18 -0800 | [diff] [blame] | 74 | "UpdateEngine.Attempt.InternalErrorCode"; |
Tianjie Xu | 98333a8 | 2017-09-22 21:29:29 -0700 | [diff] [blame] | 75 | const char kMetricAttemptDownloadErrorCode[] = |
David Zeuthen | 33bae49 | 2014-02-25 16:16:18 -0800 | [diff] [blame] | 76 | "UpdateEngine.Attempt.DownloadErrorCode"; |
| 77 | |
| 78 | // UpdateEngine.SuccessfulUpdate.* metrics. |
Tianjie Xu | 98333a8 | 2017-09-22 21:29:29 -0700 | [diff] [blame] | 79 | const char kMetricSuccessfulUpdateAttemptCount[] = |
David Zeuthen | 33bae49 | 2014-02-25 16:16:18 -0800 | [diff] [blame] | 80 | "UpdateEngine.SuccessfulUpdate.AttemptCount"; |
Tianjie Xu | 98333a8 | 2017-09-22 21:29:29 -0700 | [diff] [blame] | 81 | const char kMetricSuccessfulUpdateBytesDownloadedMiB[] = |
David Zeuthen | 33bae49 | 2014-02-25 16:16:18 -0800 | [diff] [blame] | 82 | "UpdateEngine.SuccessfulUpdate.BytesDownloadedMiB"; |
Tianjie Xu | 98333a8 | 2017-09-22 21:29:29 -0700 | [diff] [blame] | 83 | const char kMetricSuccessfulUpdateDownloadOverheadPercentage[] = |
David Zeuthen | 33bae49 | 2014-02-25 16:16:18 -0800 | [diff] [blame] | 84 | "UpdateEngine.SuccessfulUpdate.DownloadOverheadPercentage"; |
Tianjie Xu | 98333a8 | 2017-09-22 21:29:29 -0700 | [diff] [blame] | 85 | const char kMetricSuccessfulUpdateDownloadSourcesUsed[] = |
David Zeuthen | 33bae49 | 2014-02-25 16:16:18 -0800 | [diff] [blame] | 86 | "UpdateEngine.SuccessfulUpdate.DownloadSourcesUsed"; |
Tianjie Xu | 98333a8 | 2017-09-22 21:29:29 -0700 | [diff] [blame] | 87 | const char kMetricSuccessfulUpdatePayloadType[] = |
David Zeuthen | 33bae49 | 2014-02-25 16:16:18 -0800 | [diff] [blame] | 88 | "UpdateEngine.SuccessfulUpdate.PayloadType"; |
Tianjie Xu | 98333a8 | 2017-09-22 21:29:29 -0700 | [diff] [blame] | 89 | const char kMetricSuccessfulUpdatePayloadSizeMiB[] = |
David Zeuthen | 33bae49 | 2014-02-25 16:16:18 -0800 | [diff] [blame] | 90 | "UpdateEngine.SuccessfulUpdate.PayloadSizeMiB"; |
Tianjie Xu | 98333a8 | 2017-09-22 21:29:29 -0700 | [diff] [blame] | 91 | const char kMetricSuccessfulUpdateRebootCount[] = |
David Zeuthen | 33bae49 | 2014-02-25 16:16:18 -0800 | [diff] [blame] | 92 | "UpdateEngine.SuccessfulUpdate.RebootCount"; |
Tianjie Xu | 98333a8 | 2017-09-22 21:29:29 -0700 | [diff] [blame] | 93 | const char kMetricSuccessfulUpdateTotalDurationMinutes[] = |
David Zeuthen | 33bae49 | 2014-02-25 16:16:18 -0800 | [diff] [blame] | 94 | "UpdateEngine.SuccessfulUpdate.TotalDurationMinutes"; |
Tianjie Xu | 98333a8 | 2017-09-22 21:29:29 -0700 | [diff] [blame] | 95 | const char kMetricSuccessfulUpdateUpdatesAbandonedCount[] = |
David Zeuthen | 33bae49 | 2014-02-25 16:16:18 -0800 | [diff] [blame] | 96 | "UpdateEngine.SuccessfulUpdate.UpdatesAbandonedCount"; |
Tianjie Xu | 98333a8 | 2017-09-22 21:29:29 -0700 | [diff] [blame] | 97 | const char kMetricSuccessfulUpdateUrlSwitchCount[] = |
David Zeuthen | 33bae49 | 2014-02-25 16:16:18 -0800 | [diff] [blame] | 98 | "UpdateEngine.SuccessfulUpdate.UrlSwitchCount"; |
| 99 | |
David Zeuthen | 96197df | 2014-04-16 12:22:39 -0700 | [diff] [blame] | 100 | // UpdateEngine.Rollback.* metric. |
Tianjie Xu | 98333a8 | 2017-09-22 21:29:29 -0700 | [diff] [blame] | 101 | const char kMetricRollbackResult[] = "UpdateEngine.Rollback.Result"; |
David Zeuthen | 96197df | 2014-04-16 12:22:39 -0700 | [diff] [blame] | 102 | |
Alex Deymo | c1c17b4 | 2015-11-23 03:53:15 -0300 | [diff] [blame] | 103 | // UpdateEngine.CertificateCheck.* metrics. |
Tianjie Xu | 98333a8 | 2017-09-22 21:29:29 -0700 | [diff] [blame] | 104 | const char kMetricCertificateCheckUpdateCheck[] = |
Alex Deymo | c1c17b4 | 2015-11-23 03:53:15 -0300 | [diff] [blame] | 105 | "UpdateEngine.CertificateCheck.UpdateCheck"; |
Tianjie Xu | 98333a8 | 2017-09-22 21:29:29 -0700 | [diff] [blame] | 106 | const char kMetricCertificateCheckDownload[] = |
Alex Deymo | c1c17b4 | 2015-11-23 03:53:15 -0300 | [diff] [blame] | 107 | "UpdateEngine.CertificateCheck.Download"; |
| 108 | |
David Zeuthen | 33bae49 | 2014-02-25 16:16:18 -0800 | [diff] [blame] | 109 | // UpdateEngine.* metrics. |
Tianjie Xu | 98333a8 | 2017-09-22 21:29:29 -0700 | [diff] [blame] | 110 | const char kMetricFailedUpdateCount[] = "UpdateEngine.FailedUpdateCount"; |
| 111 | const char kMetricInstallDateProvisioningSource[] = |
David Zeuthen | 33bae49 | 2014-02-25 16:16:18 -0800 | [diff] [blame] | 112 | "UpdateEngine.InstallDateProvisioningSource"; |
Tianjie Xu | 98333a8 | 2017-09-22 21:29:29 -0700 | [diff] [blame] | 113 | const char kMetricTimeToRebootMinutes[] = "UpdateEngine.TimeToRebootMinutes"; |
| 114 | |
Tianjie Xu | d4c5deb | 2017-10-24 11:17:03 -0700 | [diff] [blame] | 115 | std::unique_ptr<MetricsReporterInterface> CreateMetricsReporter() { |
| 116 | return std::make_unique<MetricsReporterOmaha>(); |
| 117 | } |
| 118 | |
Tianjie Xu | 98333a8 | 2017-09-22 21:29:29 -0700 | [diff] [blame] | 119 | } // namespace metrics |
| 120 | |
| 121 | MetricsReporterOmaha::MetricsReporterOmaha() |
| 122 | : metrics_lib_(new MetricsLibrary()) {} |
David Zeuthen | 33bae49 | 2014-02-25 16:16:18 -0800 | [diff] [blame] | 123 | |
Tianjie Xu | 282aa1f | 2017-09-05 13:42:45 -0700 | [diff] [blame] | 124 | void MetricsReporterOmaha::Initialize() { |
Tianjie Xu | 98333a8 | 2017-09-22 21:29:29 -0700 | [diff] [blame] | 125 | metrics_lib_->Init(); |
David Zeuthen | 33bae49 | 2014-02-25 16:16:18 -0800 | [diff] [blame] | 126 | } |
| 127 | |
Tianjie Xu | 282aa1f | 2017-09-05 13:42:45 -0700 | [diff] [blame] | 128 | void MetricsReporterOmaha::ReportDailyMetrics(base::TimeDelta os_age) { |
Tianjie Xu | 98333a8 | 2017-09-22 21:29:29 -0700 | [diff] [blame] | 129 | string metric = metrics::kMetricDailyOSAgeDays; |
Tianjie Xu | 282aa1f | 2017-09-05 13:42:45 -0700 | [diff] [blame] | 130 | LOG(INFO) << "Uploading " << utils::FormatTimeDelta(os_age) << " for metric " |
| 131 | << metric; |
Tianjie Xu | 98333a8 | 2017-09-22 21:29:29 -0700 | [diff] [blame] | 132 | metrics_lib_->SendToUMA(metric, |
| 133 | static_cast<int>(os_age.InDays()), |
| 134 | 0, // min: 0 days |
| 135 | 6 * 30, // max: 6 months (approx) |
| 136 | 50); // num_buckets |
Tianjie Xu | 282aa1f | 2017-09-05 13:42:45 -0700 | [diff] [blame] | 137 | } |
| 138 | |
| 139 | void MetricsReporterOmaha::ReportUpdateCheckMetrics( |
| 140 | SystemState* system_state, |
| 141 | metrics::CheckResult result, |
| 142 | metrics::CheckReaction reaction, |
| 143 | metrics::DownloadErrorCode download_error_code) { |
David Zeuthen | 33bae49 | 2014-02-25 16:16:18 -0800 | [diff] [blame] | 144 | string metric; |
| 145 | int value; |
| 146 | int max_value; |
| 147 | |
| 148 | if (result != metrics::CheckResult::kUnset) { |
Tianjie Xu | 98333a8 | 2017-09-22 21:29:29 -0700 | [diff] [blame] | 149 | metric = metrics::kMetricCheckResult; |
David Zeuthen | 33bae49 | 2014-02-25 16:16:18 -0800 | [diff] [blame] | 150 | value = static_cast<int>(result); |
| 151 | max_value = static_cast<int>(metrics::CheckResult::kNumConstants) - 1; |
| 152 | LOG(INFO) << "Sending " << value << " for metric " << metric << " (enum)"; |
Tianjie Xu | 98333a8 | 2017-09-22 21:29:29 -0700 | [diff] [blame] | 153 | metrics_lib_->SendEnumToUMA(metric, value, max_value); |
David Zeuthen | 33bae49 | 2014-02-25 16:16:18 -0800 | [diff] [blame] | 154 | } |
| 155 | if (reaction != metrics::CheckReaction::kUnset) { |
Tianjie Xu | 98333a8 | 2017-09-22 21:29:29 -0700 | [diff] [blame] | 156 | metric = metrics::kMetricCheckReaction; |
David Zeuthen | 33bae49 | 2014-02-25 16:16:18 -0800 | [diff] [blame] | 157 | value = static_cast<int>(reaction); |
| 158 | max_value = static_cast<int>(metrics::CheckReaction::kNumConstants) - 1; |
| 159 | LOG(INFO) << "Sending " << value << " for metric " << metric << " (enum)"; |
Tianjie Xu | 98333a8 | 2017-09-22 21:29:29 -0700 | [diff] [blame] | 160 | metrics_lib_->SendEnumToUMA(metric, value, max_value); |
David Zeuthen | 33bae49 | 2014-02-25 16:16:18 -0800 | [diff] [blame] | 161 | } |
| 162 | if (download_error_code != metrics::DownloadErrorCode::kUnset) { |
Tianjie Xu | 98333a8 | 2017-09-22 21:29:29 -0700 | [diff] [blame] | 163 | metric = metrics::kMetricCheckDownloadErrorCode; |
David Zeuthen | 33bae49 | 2014-02-25 16:16:18 -0800 | [diff] [blame] | 164 | value = static_cast<int>(download_error_code); |
David Zeuthen | c0dd021 | 2014-04-04 14:49:49 -0700 | [diff] [blame] | 165 | LOG(INFO) << "Sending " << value << " for metric " << metric << " (sparse)"; |
Tianjie Xu | 98333a8 | 2017-09-22 21:29:29 -0700 | [diff] [blame] | 166 | metrics_lib_->SendSparseToUMA(metric, value); |
David Zeuthen | 33bae49 | 2014-02-25 16:16:18 -0800 | [diff] [blame] | 167 | } |
| 168 | |
| 169 | base::TimeDelta time_since_last; |
Alex Deymo | a259179 | 2015-11-17 00:39:40 -0300 | [diff] [blame] | 170 | if (metrics_utils::WallclockDurationHelper( |
| 171 | system_state, |
| 172 | kPrefsMetricsCheckLastReportingTime, |
| 173 | &time_since_last)) { |
Tianjie Xu | 98333a8 | 2017-09-22 21:29:29 -0700 | [diff] [blame] | 174 | metric = metrics::kMetricCheckTimeSinceLastCheckMinutes; |
David Zeuthen | 33bae49 | 2014-02-25 16:16:18 -0800 | [diff] [blame] | 175 | LOG(INFO) << "Sending " << utils::FormatTimeDelta(time_since_last) |
| 176 | << " for metric " << metric; |
Tianjie Xu | 98333a8 | 2017-09-22 21:29:29 -0700 | [diff] [blame] | 177 | metrics_lib_->SendToUMA(metric, |
| 178 | time_since_last.InMinutes(), |
| 179 | 0, // min: 0 min |
| 180 | 30 * 24 * 60, // max: 30 days |
| 181 | 50); // num_buckets |
David Zeuthen | 33bae49 | 2014-02-25 16:16:18 -0800 | [diff] [blame] | 182 | } |
| 183 | |
| 184 | base::TimeDelta uptime_since_last; |
| 185 | static int64_t uptime_since_last_storage = 0; |
Tianjie Xu | 282aa1f | 2017-09-05 13:42:45 -0700 | [diff] [blame] | 186 | if (metrics_utils::MonotonicDurationHelper( |
| 187 | system_state, &uptime_since_last_storage, &uptime_since_last)) { |
Tianjie Xu | 98333a8 | 2017-09-22 21:29:29 -0700 | [diff] [blame] | 188 | metric = metrics::kMetricCheckTimeSinceLastCheckUptimeMinutes; |
David Zeuthen | 33bae49 | 2014-02-25 16:16:18 -0800 | [diff] [blame] | 189 | LOG(INFO) << "Sending " << utils::FormatTimeDelta(uptime_since_last) |
| 190 | << " for metric " << metric; |
Tianjie Xu | 98333a8 | 2017-09-22 21:29:29 -0700 | [diff] [blame] | 191 | metrics_lib_->SendToUMA(metric, |
| 192 | uptime_since_last.InMinutes(), |
| 193 | 0, // min: 0 min |
| 194 | 30 * 24 * 60, // max: 30 days |
| 195 | 50); // num_buckets |
David Zeuthen | 33bae49 | 2014-02-25 16:16:18 -0800 | [diff] [blame] | 196 | } |
| 197 | } |
| 198 | |
Tianjie Xu | 282aa1f | 2017-09-05 13:42:45 -0700 | [diff] [blame] | 199 | void MetricsReporterOmaha::ReportAbnormallyTerminatedUpdateAttemptMetrics() { |
Tianjie Xu | 98333a8 | 2017-09-22 21:29:29 -0700 | [diff] [blame] | 200 | string metric = metrics::kMetricAttemptResult; |
Tianjie Xu | 282aa1f | 2017-09-05 13:42:45 -0700 | [diff] [blame] | 201 | metrics::AttemptResult attempt_result = |
| 202 | metrics::AttemptResult::kAbnormalTermination; |
David Zeuthen | 4e1d149 | 2014-04-25 13:12:27 -0700 | [diff] [blame] | 203 | |
| 204 | LOG(INFO) << "Uploading " << static_cast<int>(attempt_result) |
Tianjie Xu | 282aa1f | 2017-09-05 13:42:45 -0700 | [diff] [blame] | 205 | << " for metric " << metric; |
Tianjie Xu | 98333a8 | 2017-09-22 21:29:29 -0700 | [diff] [blame] | 206 | metrics_lib_->SendEnumToUMA( |
David Zeuthen | 4e1d149 | 2014-04-25 13:12:27 -0700 | [diff] [blame] | 207 | metric, |
| 208 | static_cast<int>(attempt_result), |
Tianjie Xu | 282aa1f | 2017-09-05 13:42:45 -0700 | [diff] [blame] | 209 | static_cast<int>(metrics::AttemptResult::kNumConstants)); |
David Zeuthen | 4e1d149 | 2014-04-25 13:12:27 -0700 | [diff] [blame] | 210 | } |
| 211 | |
Tianjie Xu | 282aa1f | 2017-09-05 13:42:45 -0700 | [diff] [blame] | 212 | void MetricsReporterOmaha::ReportUpdateAttemptMetrics( |
| 213 | SystemState* system_state, |
David Zeuthen | 33bae49 | 2014-02-25 16:16:18 -0800 | [diff] [blame] | 214 | int attempt_number, |
| 215 | PayloadType payload_type, |
| 216 | base::TimeDelta duration, |
| 217 | base::TimeDelta duration_uptime, |
| 218 | int64_t payload_size, |
Tianjie Xu | 282aa1f | 2017-09-05 13:42:45 -0700 | [diff] [blame] | 219 | metrics::AttemptResult attempt_result, |
Tianjie Xu | 1f93d09 | 2017-10-09 12:13:29 -0700 | [diff] [blame] | 220 | ErrorCode internal_error_code) { |
Tianjie Xu | 98333a8 | 2017-09-22 21:29:29 -0700 | [diff] [blame] | 221 | string metric = metrics::kMetricAttemptNumber; |
Tianjie Xu | 282aa1f | 2017-09-05 13:42:45 -0700 | [diff] [blame] | 222 | LOG(INFO) << "Uploading " << attempt_number << " for metric " << metric; |
Tianjie Xu | 98333a8 | 2017-09-22 21:29:29 -0700 | [diff] [blame] | 223 | metrics_lib_->SendToUMA(metric, |
| 224 | attempt_number, |
| 225 | 0, // min: 0 attempts |
| 226 | 49, // max: 49 attempts |
| 227 | 50); // num_buckets |
David Zeuthen | 33bae49 | 2014-02-25 16:16:18 -0800 | [diff] [blame] | 228 | |
Tianjie Xu | 98333a8 | 2017-09-22 21:29:29 -0700 | [diff] [blame] | 229 | metric = metrics::kMetricAttemptPayloadType; |
Tianjie Xu | 282aa1f | 2017-09-05 13:42:45 -0700 | [diff] [blame] | 230 | LOG(INFO) << "Uploading " << utils::ToString(payload_type) << " for metric " |
| 231 | << metric; |
Tianjie Xu | 98333a8 | 2017-09-22 21:29:29 -0700 | [diff] [blame] | 232 | metrics_lib_->SendEnumToUMA(metric, payload_type, kNumPayloadTypes); |
David Zeuthen | 33bae49 | 2014-02-25 16:16:18 -0800 | [diff] [blame] | 233 | |
Tianjie Xu | 98333a8 | 2017-09-22 21:29:29 -0700 | [diff] [blame] | 234 | metric = metrics::kMetricAttemptDurationMinutes; |
David Zeuthen | 33bae49 | 2014-02-25 16:16:18 -0800 | [diff] [blame] | 235 | LOG(INFO) << "Uploading " << utils::FormatTimeDelta(duration) |
Tianjie Xu | 282aa1f | 2017-09-05 13:42:45 -0700 | [diff] [blame] | 236 | << " for metric " << metric; |
Tianjie Xu | 98333a8 | 2017-09-22 21:29:29 -0700 | [diff] [blame] | 237 | metrics_lib_->SendToUMA(metric, |
| 238 | duration.InMinutes(), |
| 239 | 0, // min: 0 min |
| 240 | 10 * 24 * 60, // max: 10 days |
| 241 | 50); // num_buckets |
David Zeuthen | 33bae49 | 2014-02-25 16:16:18 -0800 | [diff] [blame] | 242 | |
Tianjie Xu | 98333a8 | 2017-09-22 21:29:29 -0700 | [diff] [blame] | 243 | metric = metrics::kMetricAttemptDurationUptimeMinutes; |
David Zeuthen | 33bae49 | 2014-02-25 16:16:18 -0800 | [diff] [blame] | 244 | LOG(INFO) << "Uploading " << utils::FormatTimeDelta(duration_uptime) |
Tianjie Xu | 282aa1f | 2017-09-05 13:42:45 -0700 | [diff] [blame] | 245 | << " for metric " << metric; |
Tianjie Xu | 98333a8 | 2017-09-22 21:29:29 -0700 | [diff] [blame] | 246 | metrics_lib_->SendToUMA(metric, |
| 247 | duration_uptime.InMinutes(), |
| 248 | 0, // min: 0 min |
| 249 | 10 * 24 * 60, // max: 10 days |
| 250 | 50); // num_buckets |
David Zeuthen | 33bae49 | 2014-02-25 16:16:18 -0800 | [diff] [blame] | 251 | |
Tianjie Xu | 98333a8 | 2017-09-22 21:29:29 -0700 | [diff] [blame] | 252 | metric = metrics::kMetricAttemptPayloadSizeMiB; |
David Zeuthen | 33bae49 | 2014-02-25 16:16:18 -0800 | [diff] [blame] | 253 | int64_t payload_size_mib = payload_size / kNumBytesInOneMiB; |
Tianjie Xu | 282aa1f | 2017-09-05 13:42:45 -0700 | [diff] [blame] | 254 | LOG(INFO) << "Uploading " << payload_size_mib << " for metric " << metric; |
Tianjie Xu | 98333a8 | 2017-09-22 21:29:29 -0700 | [diff] [blame] | 255 | metrics_lib_->SendToUMA(metric, |
| 256 | payload_size_mib, |
| 257 | 0, // min: 0 MiB |
| 258 | 1024, // max: 1024 MiB = 1 GiB |
| 259 | 50); // num_buckets |
David Zeuthen | 33bae49 | 2014-02-25 16:16:18 -0800 | [diff] [blame] | 260 | |
David Zeuthen | 33bae49 | 2014-02-25 16:16:18 -0800 | [diff] [blame] | 261 | |
David Zeuthen | 33bae49 | 2014-02-25 16:16:18 -0800 | [diff] [blame] | 262 | |
Tianjie Xu | 98333a8 | 2017-09-22 21:29:29 -0700 | [diff] [blame] | 263 | metric = metrics::kMetricAttemptResult; |
David Zeuthen | 33bae49 | 2014-02-25 16:16:18 -0800 | [diff] [blame] | 264 | LOG(INFO) << "Uploading " << static_cast<int>(attempt_result) |
Tianjie Xu | 282aa1f | 2017-09-05 13:42:45 -0700 | [diff] [blame] | 265 | << " for metric " << metric; |
Tianjie Xu | 98333a8 | 2017-09-22 21:29:29 -0700 | [diff] [blame] | 266 | metrics_lib_->SendEnumToUMA( |
David Zeuthen | 33bae49 | 2014-02-25 16:16:18 -0800 | [diff] [blame] | 267 | metric, |
| 268 | static_cast<int>(attempt_result), |
Tianjie Xu | 282aa1f | 2017-09-05 13:42:45 -0700 | [diff] [blame] | 269 | static_cast<int>(metrics::AttemptResult::kNumConstants)); |
David Zeuthen | 33bae49 | 2014-02-25 16:16:18 -0800 | [diff] [blame] | 270 | |
Gilad Arnold | d1c4d2d | 2014-06-05 14:07:53 -0700 | [diff] [blame] | 271 | if (internal_error_code != ErrorCode::kSuccess) { |
Amin Hassani | 80f4d4c | 2018-05-16 13:34:00 -0700 | [diff] [blame^] | 272 | ReportInternalErrorCode(internal_error_code); |
David Zeuthen | 33bae49 | 2014-02-25 16:16:18 -0800 | [diff] [blame] | 273 | } |
| 274 | |
David Zeuthen | 33bae49 | 2014-02-25 16:16:18 -0800 | [diff] [blame] | 275 | base::TimeDelta time_since_last; |
Alex Deymo | a259179 | 2015-11-17 00:39:40 -0300 | [diff] [blame] | 276 | if (metrics_utils::WallclockDurationHelper( |
| 277 | system_state, |
| 278 | kPrefsMetricsAttemptLastReportingTime, |
| 279 | &time_since_last)) { |
Tianjie Xu | 98333a8 | 2017-09-22 21:29:29 -0700 | [diff] [blame] | 280 | metric = metrics::kMetricAttemptTimeSinceLastAttemptMinutes; |
David Zeuthen | 33bae49 | 2014-02-25 16:16:18 -0800 | [diff] [blame] | 281 | LOG(INFO) << "Sending " << utils::FormatTimeDelta(time_since_last) |
| 282 | << " for metric " << metric; |
Tianjie Xu | 98333a8 | 2017-09-22 21:29:29 -0700 | [diff] [blame] | 283 | metrics_lib_->SendToUMA(metric, |
| 284 | time_since_last.InMinutes(), |
| 285 | 0, // min: 0 min |
| 286 | 30 * 24 * 60, // max: 30 days |
| 287 | 50); // num_buckets |
David Zeuthen | 33bae49 | 2014-02-25 16:16:18 -0800 | [diff] [blame] | 288 | } |
| 289 | |
| 290 | static int64_t uptime_since_last_storage = 0; |
| 291 | base::TimeDelta uptime_since_last; |
Tianjie Xu | 282aa1f | 2017-09-05 13:42:45 -0700 | [diff] [blame] | 292 | if (metrics_utils::MonotonicDurationHelper( |
| 293 | system_state, &uptime_since_last_storage, &uptime_since_last)) { |
Tianjie Xu | 98333a8 | 2017-09-22 21:29:29 -0700 | [diff] [blame] | 294 | metric = metrics::kMetricAttemptTimeSinceLastAttemptUptimeMinutes; |
David Zeuthen | 33bae49 | 2014-02-25 16:16:18 -0800 | [diff] [blame] | 295 | LOG(INFO) << "Sending " << utils::FormatTimeDelta(uptime_since_last) |
| 296 | << " for metric " << metric; |
Tianjie Xu | 98333a8 | 2017-09-22 21:29:29 -0700 | [diff] [blame] | 297 | metrics_lib_->SendToUMA(metric, |
| 298 | uptime_since_last.InMinutes(), |
| 299 | 0, // min: 0 min |
| 300 | 30 * 24 * 60, // max: 30 days |
| 301 | 50); // num_buckets |
David Zeuthen | 33bae49 | 2014-02-25 16:16:18 -0800 | [diff] [blame] | 302 | } |
Tianjie Xu | 1f93d09 | 2017-10-09 12:13:29 -0700 | [diff] [blame] | 303 | } |
| 304 | |
| 305 | void MetricsReporterOmaha::ReportUpdateAttemptDownloadMetrics( |
| 306 | int64_t payload_bytes_downloaded, |
| 307 | int64_t payload_download_speed_bps, |
| 308 | DownloadSource download_source, |
| 309 | metrics::DownloadErrorCode payload_download_error_code, |
| 310 | metrics::ConnectionType connection_type) { |
| 311 | string metric = metrics::kMetricAttemptPayloadBytesDownloadedMiB; |
| 312 | int64_t payload_bytes_downloaded_mib = |
| 313 | payload_bytes_downloaded / kNumBytesInOneMiB; |
| 314 | LOG(INFO) << "Uploading " << payload_bytes_downloaded_mib << " for metric " |
| 315 | << metric; |
| 316 | metrics_lib_->SendToUMA(metric, |
| 317 | payload_bytes_downloaded_mib, |
| 318 | 0, // min: 0 MiB |
| 319 | 1024, // max: 1024 MiB = 1 GiB |
| 320 | 50); // num_buckets |
| 321 | |
| 322 | metric = metrics::kMetricAttemptPayloadDownloadSpeedKBps; |
| 323 | int64_t payload_download_speed_kbps = payload_download_speed_bps / 1000; |
| 324 | LOG(INFO) << "Uploading " << payload_download_speed_kbps << " for metric " |
| 325 | << metric; |
| 326 | metrics_lib_->SendToUMA(metric, |
| 327 | payload_download_speed_kbps, |
| 328 | 0, // min: 0 kB/s |
| 329 | 10 * 1000, // max: 10000 kB/s = 10 MB/s |
| 330 | 50); // num_buckets |
| 331 | |
| 332 | metric = metrics::kMetricAttemptDownloadSource; |
| 333 | LOG(INFO) << "Uploading " << download_source << " for metric " << metric; |
| 334 | metrics_lib_->SendEnumToUMA(metric, download_source, kNumDownloadSources); |
| 335 | |
| 336 | if (payload_download_error_code != metrics::DownloadErrorCode::kUnset) { |
| 337 | metric = metrics::kMetricAttemptDownloadErrorCode; |
| 338 | LOG(INFO) << "Uploading " << static_cast<int>(payload_download_error_code) |
| 339 | << " for metric " << metric << " (sparse)"; |
| 340 | metrics_lib_->SendSparseToUMA( |
| 341 | metric, static_cast<int>(payload_download_error_code)); |
| 342 | } |
David Zeuthen | b281f07 | 2014-04-02 10:20:19 -0700 | [diff] [blame] | 343 | |
Tianjie Xu | 98333a8 | 2017-09-22 21:29:29 -0700 | [diff] [blame] | 344 | metric = metrics::kMetricAttemptConnectionType; |
David Zeuthen | b281f07 | 2014-04-02 10:20:19 -0700 | [diff] [blame] | 345 | LOG(INFO) << "Uploading " << static_cast<int>(connection_type) |
Tianjie Xu | 282aa1f | 2017-09-05 13:42:45 -0700 | [diff] [blame] | 346 | << " for metric " << metric; |
Tianjie Xu | 98333a8 | 2017-09-22 21:29:29 -0700 | [diff] [blame] | 347 | metrics_lib_->SendEnumToUMA( |
David Zeuthen | b281f07 | 2014-04-02 10:20:19 -0700 | [diff] [blame] | 348 | metric, |
| 349 | static_cast<int>(connection_type), |
Tianjie Xu | 282aa1f | 2017-09-05 13:42:45 -0700 | [diff] [blame] | 350 | static_cast<int>(metrics::ConnectionType::kNumConstants)); |
David Zeuthen | 33bae49 | 2014-02-25 16:16:18 -0800 | [diff] [blame] | 351 | } |
| 352 | |
Tianjie Xu | 282aa1f | 2017-09-05 13:42:45 -0700 | [diff] [blame] | 353 | void MetricsReporterOmaha::ReportSuccessfulUpdateMetrics( |
| 354 | int attempt_count, |
| 355 | int updates_abandoned_count, |
| 356 | PayloadType payload_type, |
| 357 | int64_t payload_size, |
| 358 | int64_t num_bytes_downloaded[kNumDownloadSources], |
| 359 | int download_overhead_percentage, |
| 360 | base::TimeDelta total_duration, |
| 361 | int reboot_count, |
| 362 | int url_switch_count) { |
Tianjie Xu | 98333a8 | 2017-09-22 21:29:29 -0700 | [diff] [blame] | 363 | string metric = metrics::kMetricSuccessfulUpdatePayloadSizeMiB; |
Tianjie Xu | 282aa1f | 2017-09-05 13:42:45 -0700 | [diff] [blame] | 364 | int64_t mbs = payload_size / kNumBytesInOneMiB; |
David Zeuthen | 33bae49 | 2014-02-25 16:16:18 -0800 | [diff] [blame] | 365 | LOG(INFO) << "Uploading " << mbs << " (MiBs) for metric " << metric; |
Tianjie Xu | 98333a8 | 2017-09-22 21:29:29 -0700 | [diff] [blame] | 366 | metrics_lib_->SendToUMA(metric, |
| 367 | mbs, |
| 368 | 0, // min: 0 MiB |
| 369 | 1024, // max: 1024 MiB = 1 GiB |
| 370 | 50); // num_buckets |
David Zeuthen | 33bae49 | 2014-02-25 16:16:18 -0800 | [diff] [blame] | 371 | |
| 372 | int64_t total_bytes = 0; |
| 373 | int download_sources_used = 0; |
| 374 | for (int i = 0; i < kNumDownloadSources + 1; i++) { |
| 375 | DownloadSource source = static_cast<DownloadSource>(i); |
| 376 | |
| 377 | // Only consider this download source (and send byte counts) as |
| 378 | // having been used if we downloaded a non-trivial amount of bytes |
Alex Vakulenko | 072359c | 2014-07-18 11:41:07 -0700 | [diff] [blame] | 379 | // (e.g. at least 1 MiB) that contributed to the |
David Zeuthen | 33bae49 | 2014-02-25 16:16:18 -0800 | [diff] [blame] | 380 | // update. Otherwise we're going to end up with a lot of zero-byte |
| 381 | // events in the histogram. |
| 382 | |
Tianjie Xu | 98333a8 | 2017-09-22 21:29:29 -0700 | [diff] [blame] | 383 | metric = metrics::kMetricSuccessfulUpdateBytesDownloadedMiB; |
David Zeuthen | 33bae49 | 2014-02-25 16:16:18 -0800 | [diff] [blame] | 384 | if (i < kNumDownloadSources) { |
| 385 | metric += utils::ToString(source); |
| 386 | mbs = num_bytes_downloaded[i] / kNumBytesInOneMiB; |
| 387 | total_bytes += num_bytes_downloaded[i]; |
| 388 | if (mbs > 0) |
| 389 | download_sources_used |= (1 << i); |
| 390 | } else { |
| 391 | mbs = total_bytes / kNumBytesInOneMiB; |
| 392 | } |
| 393 | |
| 394 | if (mbs > 0) { |
| 395 | LOG(INFO) << "Uploading " << mbs << " (MiBs) for metric " << metric; |
Tianjie Xu | 98333a8 | 2017-09-22 21:29:29 -0700 | [diff] [blame] | 396 | metrics_lib_->SendToUMA(metric, |
| 397 | mbs, |
| 398 | 0, // min: 0 MiB |
| 399 | 1024, // max: 1024 MiB = 1 GiB |
| 400 | 50); // num_buckets |
David Zeuthen | 33bae49 | 2014-02-25 16:16:18 -0800 | [diff] [blame] | 401 | } |
| 402 | } |
| 403 | |
Tianjie Xu | 98333a8 | 2017-09-22 21:29:29 -0700 | [diff] [blame] | 404 | metric = metrics::kMetricSuccessfulUpdateDownloadSourcesUsed; |
David Zeuthen | 33bae49 | 2014-02-25 16:16:18 -0800 | [diff] [blame] | 405 | LOG(INFO) << "Uploading 0x" << std::hex << download_sources_used |
| 406 | << " (bit flags) for metric " << metric; |
Tianjie Xu | 98333a8 | 2017-09-22 21:29:29 -0700 | [diff] [blame] | 407 | metrics_lib_->SendToUMA(metric, |
| 408 | download_sources_used, |
| 409 | 0, // min |
| 410 | (1 << kNumDownloadSources) - 1, // max |
| 411 | 1 << kNumDownloadSources); // num_buckets |
David Zeuthen | 33bae49 | 2014-02-25 16:16:18 -0800 | [diff] [blame] | 412 | |
Tianjie Xu | 98333a8 | 2017-09-22 21:29:29 -0700 | [diff] [blame] | 413 | metric = metrics::kMetricSuccessfulUpdateDownloadOverheadPercentage; |
Tianjie Xu | 282aa1f | 2017-09-05 13:42:45 -0700 | [diff] [blame] | 414 | LOG(INFO) << "Uploading " << download_overhead_percentage << "% for metric " |
| 415 | << metric; |
Tianjie Xu | 98333a8 | 2017-09-22 21:29:29 -0700 | [diff] [blame] | 416 | metrics_lib_->SendToUMA(metric, |
| 417 | download_overhead_percentage, |
| 418 | 0, // min: 0% overhead |
| 419 | 1000, // max: 1000% overhead |
| 420 | 50); // num_buckets |
David Zeuthen | 33bae49 | 2014-02-25 16:16:18 -0800 | [diff] [blame] | 421 | |
Tianjie Xu | 98333a8 | 2017-09-22 21:29:29 -0700 | [diff] [blame] | 422 | metric = metrics::kMetricSuccessfulUpdateUrlSwitchCount; |
Tianjie Xu | 282aa1f | 2017-09-05 13:42:45 -0700 | [diff] [blame] | 423 | LOG(INFO) << "Uploading " << url_switch_count << " (count) for metric " |
| 424 | << metric; |
Tianjie Xu | 98333a8 | 2017-09-22 21:29:29 -0700 | [diff] [blame] | 425 | metrics_lib_->SendToUMA(metric, |
| 426 | url_switch_count, |
| 427 | 0, // min: 0 URL switches |
| 428 | 49, // max: 49 URL switches |
| 429 | 50); // num_buckets |
David Zeuthen | 33bae49 | 2014-02-25 16:16:18 -0800 | [diff] [blame] | 430 | |
Tianjie Xu | 98333a8 | 2017-09-22 21:29:29 -0700 | [diff] [blame] | 431 | metric = metrics::kMetricSuccessfulUpdateTotalDurationMinutes; |
David Zeuthen | 33bae49 | 2014-02-25 16:16:18 -0800 | [diff] [blame] | 432 | LOG(INFO) << "Uploading " << utils::FormatTimeDelta(total_duration) |
Tianjie Xu | 282aa1f | 2017-09-05 13:42:45 -0700 | [diff] [blame] | 433 | << " for metric " << metric; |
Tianjie Xu | 98333a8 | 2017-09-22 21:29:29 -0700 | [diff] [blame] | 434 | metrics_lib_->SendToUMA(metric, |
| 435 | static_cast<int>(total_duration.InMinutes()), |
| 436 | 0, // min: 0 min |
| 437 | 365 * 24 * 60, // max: 365 days ~= 1 year |
| 438 | 50); // num_buckets |
David Zeuthen | 33bae49 | 2014-02-25 16:16:18 -0800 | [diff] [blame] | 439 | |
Tianjie Xu | 98333a8 | 2017-09-22 21:29:29 -0700 | [diff] [blame] | 440 | metric = metrics::kMetricSuccessfulUpdateRebootCount; |
David Zeuthen | 33bae49 | 2014-02-25 16:16:18 -0800 | [diff] [blame] | 441 | LOG(INFO) << "Uploading reboot count of " << reboot_count << " for metric " |
Tianjie Xu | 282aa1f | 2017-09-05 13:42:45 -0700 | [diff] [blame] | 442 | << metric; |
Tianjie Xu | 98333a8 | 2017-09-22 21:29:29 -0700 | [diff] [blame] | 443 | metrics_lib_->SendToUMA(metric, |
| 444 | reboot_count, |
| 445 | 0, // min: 0 reboots |
| 446 | 49, // max: 49 reboots |
| 447 | 50); // num_buckets |
David Zeuthen | 33bae49 | 2014-02-25 16:16:18 -0800 | [diff] [blame] | 448 | |
Tianjie Xu | 98333a8 | 2017-09-22 21:29:29 -0700 | [diff] [blame] | 449 | metric = metrics::kMetricSuccessfulUpdatePayloadType; |
| 450 | metrics_lib_->SendEnumToUMA(metric, payload_type, kNumPayloadTypes); |
Tianjie Xu | 282aa1f | 2017-09-05 13:42:45 -0700 | [diff] [blame] | 451 | LOG(INFO) << "Uploading " << utils::ToString(payload_type) << " for metric " |
| 452 | << metric; |
David Zeuthen | 33bae49 | 2014-02-25 16:16:18 -0800 | [diff] [blame] | 453 | |
Tianjie Xu | 98333a8 | 2017-09-22 21:29:29 -0700 | [diff] [blame] | 454 | metric = metrics::kMetricSuccessfulUpdateAttemptCount; |
| 455 | metrics_lib_->SendToUMA(metric, |
| 456 | attempt_count, |
| 457 | 1, // min: 1 attempt |
| 458 | 50, // max: 50 attempts |
| 459 | 50); // num_buckets |
Tianjie Xu | 282aa1f | 2017-09-05 13:42:45 -0700 | [diff] [blame] | 460 | LOG(INFO) << "Uploading " << attempt_count << " for metric " << metric; |
David Zeuthen | 33bae49 | 2014-02-25 16:16:18 -0800 | [diff] [blame] | 461 | |
Tianjie Xu | 98333a8 | 2017-09-22 21:29:29 -0700 | [diff] [blame] | 462 | metric = metrics::kMetricSuccessfulUpdateUpdatesAbandonedCount; |
Tianjie Xu | 282aa1f | 2017-09-05 13:42:45 -0700 | [diff] [blame] | 463 | LOG(INFO) << "Uploading " << updates_abandoned_count << " (count) for metric " |
| 464 | << metric; |
Tianjie Xu | 98333a8 | 2017-09-22 21:29:29 -0700 | [diff] [blame] | 465 | metrics_lib_->SendToUMA(metric, |
| 466 | updates_abandoned_count, |
| 467 | 0, // min: 0 counts |
| 468 | 49, // max: 49 counts |
| 469 | 50); // num_buckets |
David Zeuthen | 33bae49 | 2014-02-25 16:16:18 -0800 | [diff] [blame] | 470 | } |
| 471 | |
Tianjie Xu | 282aa1f | 2017-09-05 13:42:45 -0700 | [diff] [blame] | 472 | void MetricsReporterOmaha::ReportRollbackMetrics( |
| 473 | metrics::RollbackResult result) { |
Tianjie Xu | 98333a8 | 2017-09-22 21:29:29 -0700 | [diff] [blame] | 474 | string metric = metrics::kMetricRollbackResult; |
Tianjie Xu | 282aa1f | 2017-09-05 13:42:45 -0700 | [diff] [blame] | 475 | int value = static_cast<int>(result); |
David Zeuthen | 96197df | 2014-04-16 12:22:39 -0700 | [diff] [blame] | 476 | LOG(INFO) << "Sending " << value << " for metric " << metric << " (enum)"; |
Tianjie Xu | 98333a8 | 2017-09-22 21:29:29 -0700 | [diff] [blame] | 477 | metrics_lib_->SendEnumToUMA( |
Tianjie Xu | 282aa1f | 2017-09-05 13:42:45 -0700 | [diff] [blame] | 478 | metric, value, static_cast<int>(metrics::RollbackResult::kNumConstants)); |
David Zeuthen | 96197df | 2014-04-16 12:22:39 -0700 | [diff] [blame] | 479 | } |
| 480 | |
Tianjie Xu | 282aa1f | 2017-09-05 13:42:45 -0700 | [diff] [blame] | 481 | void MetricsReporterOmaha::ReportCertificateCheckMetrics( |
| 482 | ServerToCheck server_to_check, CertificateCheckResult result) { |
Alex Deymo | c1c17b4 | 2015-11-23 03:53:15 -0300 | [diff] [blame] | 483 | string metric; |
| 484 | switch (server_to_check) { |
| 485 | case ServerToCheck::kUpdate: |
Tianjie Xu | 98333a8 | 2017-09-22 21:29:29 -0700 | [diff] [blame] | 486 | metric = metrics::kMetricCertificateCheckUpdateCheck; |
Alex Deymo | c1c17b4 | 2015-11-23 03:53:15 -0300 | [diff] [blame] | 487 | break; |
| 488 | case ServerToCheck::kDownload: |
Tianjie Xu | 98333a8 | 2017-09-22 21:29:29 -0700 | [diff] [blame] | 489 | metric = metrics::kMetricCertificateCheckDownload; |
Alex Deymo | c1c17b4 | 2015-11-23 03:53:15 -0300 | [diff] [blame] | 490 | break; |
Alex Deymo | 33e91e7 | 2015-12-01 18:26:08 -0300 | [diff] [blame] | 491 | case ServerToCheck::kNone: |
| 492 | return; |
Alex Deymo | c1c17b4 | 2015-11-23 03:53:15 -0300 | [diff] [blame] | 493 | } |
| 494 | LOG(INFO) << "Uploading " << static_cast<int>(result) << " for metric " |
| 495 | << metric; |
Tianjie Xu | 98333a8 | 2017-09-22 21:29:29 -0700 | [diff] [blame] | 496 | metrics_lib_->SendEnumToUMA( |
Tianjie Xu | 282aa1f | 2017-09-05 13:42:45 -0700 | [diff] [blame] | 497 | metric, |
| 498 | static_cast<int>(result), |
Alex Deymo | c1c17b4 | 2015-11-23 03:53:15 -0300 | [diff] [blame] | 499 | static_cast<int>(CertificateCheckResult::kNumConstants)); |
| 500 | } |
| 501 | |
Tianjie Xu | 282aa1f | 2017-09-05 13:42:45 -0700 | [diff] [blame] | 502 | void MetricsReporterOmaha::ReportFailedUpdateCount(int target_attempt) { |
Tianjie Xu | 98333a8 | 2017-09-22 21:29:29 -0700 | [diff] [blame] | 503 | string metric = metrics::kMetricFailedUpdateCount; |
| 504 | metrics_lib_->SendToUMA(metric, |
| 505 | target_attempt, |
| 506 | 1, // min value |
| 507 | 50, // max value |
| 508 | kNumDefaultUmaBuckets); |
Tianjie Xu | 282aa1f | 2017-09-05 13:42:45 -0700 | [diff] [blame] | 509 | |
| 510 | LOG(INFO) << "Uploading " << target_attempt << " (count) for metric " |
| 511 | << metric; |
| 512 | } |
| 513 | |
| 514 | void MetricsReporterOmaha::ReportTimeToReboot(int time_to_reboot_minutes) { |
Tianjie Xu | 98333a8 | 2017-09-22 21:29:29 -0700 | [diff] [blame] | 515 | string metric = metrics::kMetricTimeToRebootMinutes; |
| 516 | metrics_lib_->SendToUMA(metric, |
| 517 | time_to_reboot_minutes, |
| 518 | 0, // min: 0 minute |
| 519 | 30 * 24 * 60, // max: 1 month (approx) |
| 520 | kNumDefaultUmaBuckets); |
Tianjie Xu | 282aa1f | 2017-09-05 13:42:45 -0700 | [diff] [blame] | 521 | |
| 522 | LOG(INFO) << "Uploading " << time_to_reboot_minutes << " for metric " |
| 523 | << metric; |
| 524 | } |
| 525 | |
| 526 | void MetricsReporterOmaha::ReportInstallDateProvisioningSource(int source, |
| 527 | int max) { |
Tianjie Xu | 98333a8 | 2017-09-22 21:29:29 -0700 | [diff] [blame] | 528 | metrics_lib_->SendEnumToUMA(metrics::kMetricInstallDateProvisioningSource, |
| 529 | source, // Sample. |
| 530 | max); |
Tianjie Xu | 282aa1f | 2017-09-05 13:42:45 -0700 | [diff] [blame] | 531 | } |
David Zeuthen | 33bae49 | 2014-02-25 16:16:18 -0800 | [diff] [blame] | 532 | |
Amin Hassani | 80f4d4c | 2018-05-16 13:34:00 -0700 | [diff] [blame^] | 533 | void MetricsReporterOmaha::ReportInternalErrorCode(ErrorCode error_code) { |
| 534 | auto metric = metrics::kMetricAttemptInternalErrorCode; |
| 535 | LOG(INFO) << "Uploading " << error_code << " for metric " << metric; |
| 536 | metrics_lib_->SendEnumToUMA(metric, |
| 537 | static_cast<int>(error_code), |
| 538 | static_cast<int>(ErrorCode::kUmaReportedMax)); |
| 539 | } |
| 540 | |
David Zeuthen | 33bae49 | 2014-02-25 16:16:18 -0800 | [diff] [blame] | 541 | } // namespace chromeos_update_engine |