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 | |
| 115 | } // namespace metrics |
| 116 | |
| 117 | MetricsReporterOmaha::MetricsReporterOmaha() |
| 118 | : metrics_lib_(new MetricsLibrary()) {} |
David Zeuthen | 33bae49 | 2014-02-25 16:16:18 -0800 | [diff] [blame] | 119 | |
Tianjie Xu | 282aa1f | 2017-09-05 13:42:45 -0700 | [diff] [blame] | 120 | void MetricsReporterOmaha::Initialize() { |
Tianjie Xu | 98333a8 | 2017-09-22 21:29:29 -0700 | [diff] [blame] | 121 | metrics_lib_->Init(); |
David Zeuthen | 33bae49 | 2014-02-25 16:16:18 -0800 | [diff] [blame] | 122 | } |
| 123 | |
Tianjie Xu | 282aa1f | 2017-09-05 13:42:45 -0700 | [diff] [blame] | 124 | void MetricsReporterOmaha::ReportDailyMetrics(base::TimeDelta os_age) { |
Tianjie Xu | 98333a8 | 2017-09-22 21:29:29 -0700 | [diff] [blame] | 125 | string metric = metrics::kMetricDailyOSAgeDays; |
Tianjie Xu | 282aa1f | 2017-09-05 13:42:45 -0700 | [diff] [blame] | 126 | LOG(INFO) << "Uploading " << utils::FormatTimeDelta(os_age) << " for metric " |
| 127 | << metric; |
Tianjie Xu | 98333a8 | 2017-09-22 21:29:29 -0700 | [diff] [blame] | 128 | metrics_lib_->SendToUMA(metric, |
| 129 | static_cast<int>(os_age.InDays()), |
| 130 | 0, // min: 0 days |
| 131 | 6 * 30, // max: 6 months (approx) |
| 132 | 50); // num_buckets |
Tianjie Xu | 282aa1f | 2017-09-05 13:42:45 -0700 | [diff] [blame] | 133 | } |
| 134 | |
| 135 | void MetricsReporterOmaha::ReportUpdateCheckMetrics( |
| 136 | SystemState* system_state, |
| 137 | metrics::CheckResult result, |
| 138 | metrics::CheckReaction reaction, |
| 139 | metrics::DownloadErrorCode download_error_code) { |
David Zeuthen | 33bae49 | 2014-02-25 16:16:18 -0800 | [diff] [blame] | 140 | string metric; |
| 141 | int value; |
| 142 | int max_value; |
| 143 | |
| 144 | if (result != metrics::CheckResult::kUnset) { |
Tianjie Xu | 98333a8 | 2017-09-22 21:29:29 -0700 | [diff] [blame] | 145 | metric = metrics::kMetricCheckResult; |
David Zeuthen | 33bae49 | 2014-02-25 16:16:18 -0800 | [diff] [blame] | 146 | value = static_cast<int>(result); |
| 147 | max_value = static_cast<int>(metrics::CheckResult::kNumConstants) - 1; |
| 148 | LOG(INFO) << "Sending " << value << " for metric " << metric << " (enum)"; |
Tianjie Xu | 98333a8 | 2017-09-22 21:29:29 -0700 | [diff] [blame] | 149 | metrics_lib_->SendEnumToUMA(metric, value, max_value); |
David Zeuthen | 33bae49 | 2014-02-25 16:16:18 -0800 | [diff] [blame] | 150 | } |
| 151 | if (reaction != metrics::CheckReaction::kUnset) { |
Tianjie Xu | 98333a8 | 2017-09-22 21:29:29 -0700 | [diff] [blame] | 152 | metric = metrics::kMetricCheckReaction; |
David Zeuthen | 33bae49 | 2014-02-25 16:16:18 -0800 | [diff] [blame] | 153 | value = static_cast<int>(reaction); |
| 154 | max_value = static_cast<int>(metrics::CheckReaction::kNumConstants) - 1; |
| 155 | LOG(INFO) << "Sending " << value << " for metric " << metric << " (enum)"; |
Tianjie Xu | 98333a8 | 2017-09-22 21:29:29 -0700 | [diff] [blame] | 156 | metrics_lib_->SendEnumToUMA(metric, value, max_value); |
David Zeuthen | 33bae49 | 2014-02-25 16:16:18 -0800 | [diff] [blame] | 157 | } |
| 158 | if (download_error_code != metrics::DownloadErrorCode::kUnset) { |
Tianjie Xu | 98333a8 | 2017-09-22 21:29:29 -0700 | [diff] [blame] | 159 | metric = metrics::kMetricCheckDownloadErrorCode; |
David Zeuthen | 33bae49 | 2014-02-25 16:16:18 -0800 | [diff] [blame] | 160 | value = static_cast<int>(download_error_code); |
David Zeuthen | c0dd021 | 2014-04-04 14:49:49 -0700 | [diff] [blame] | 161 | LOG(INFO) << "Sending " << value << " for metric " << metric << " (sparse)"; |
Tianjie Xu | 98333a8 | 2017-09-22 21:29:29 -0700 | [diff] [blame] | 162 | metrics_lib_->SendSparseToUMA(metric, value); |
David Zeuthen | 33bae49 | 2014-02-25 16:16:18 -0800 | [diff] [blame] | 163 | } |
| 164 | |
| 165 | base::TimeDelta time_since_last; |
Alex Deymo | a259179 | 2015-11-17 00:39:40 -0300 | [diff] [blame] | 166 | if (metrics_utils::WallclockDurationHelper( |
| 167 | system_state, |
| 168 | kPrefsMetricsCheckLastReportingTime, |
| 169 | &time_since_last)) { |
Tianjie Xu | 98333a8 | 2017-09-22 21:29:29 -0700 | [diff] [blame] | 170 | metric = metrics::kMetricCheckTimeSinceLastCheckMinutes; |
David Zeuthen | 33bae49 | 2014-02-25 16:16:18 -0800 | [diff] [blame] | 171 | LOG(INFO) << "Sending " << utils::FormatTimeDelta(time_since_last) |
| 172 | << " for metric " << metric; |
Tianjie Xu | 98333a8 | 2017-09-22 21:29:29 -0700 | [diff] [blame] | 173 | metrics_lib_->SendToUMA(metric, |
| 174 | time_since_last.InMinutes(), |
| 175 | 0, // min: 0 min |
| 176 | 30 * 24 * 60, // max: 30 days |
| 177 | 50); // num_buckets |
David Zeuthen | 33bae49 | 2014-02-25 16:16:18 -0800 | [diff] [blame] | 178 | } |
| 179 | |
| 180 | base::TimeDelta uptime_since_last; |
| 181 | static int64_t uptime_since_last_storage = 0; |
Tianjie Xu | 282aa1f | 2017-09-05 13:42:45 -0700 | [diff] [blame] | 182 | if (metrics_utils::MonotonicDurationHelper( |
| 183 | system_state, &uptime_since_last_storage, &uptime_since_last)) { |
Tianjie Xu | 98333a8 | 2017-09-22 21:29:29 -0700 | [diff] [blame] | 184 | metric = metrics::kMetricCheckTimeSinceLastCheckUptimeMinutes; |
David Zeuthen | 33bae49 | 2014-02-25 16:16:18 -0800 | [diff] [blame] | 185 | LOG(INFO) << "Sending " << utils::FormatTimeDelta(uptime_since_last) |
| 186 | << " for metric " << metric; |
Tianjie Xu | 98333a8 | 2017-09-22 21:29:29 -0700 | [diff] [blame] | 187 | metrics_lib_->SendToUMA(metric, |
| 188 | uptime_since_last.InMinutes(), |
| 189 | 0, // min: 0 min |
| 190 | 30 * 24 * 60, // max: 30 days |
| 191 | 50); // num_buckets |
David Zeuthen | 33bae49 | 2014-02-25 16:16:18 -0800 | [diff] [blame] | 192 | } |
| 193 | } |
| 194 | |
Tianjie Xu | 282aa1f | 2017-09-05 13:42:45 -0700 | [diff] [blame] | 195 | void MetricsReporterOmaha::ReportAbnormallyTerminatedUpdateAttemptMetrics() { |
Tianjie Xu | 98333a8 | 2017-09-22 21:29:29 -0700 | [diff] [blame] | 196 | string metric = metrics::kMetricAttemptResult; |
Tianjie Xu | 282aa1f | 2017-09-05 13:42:45 -0700 | [diff] [blame] | 197 | metrics::AttemptResult attempt_result = |
| 198 | metrics::AttemptResult::kAbnormalTermination; |
David Zeuthen | 4e1d149 | 2014-04-25 13:12:27 -0700 | [diff] [blame] | 199 | |
| 200 | LOG(INFO) << "Uploading " << static_cast<int>(attempt_result) |
Tianjie Xu | 282aa1f | 2017-09-05 13:42:45 -0700 | [diff] [blame] | 201 | << " for metric " << metric; |
Tianjie Xu | 98333a8 | 2017-09-22 21:29:29 -0700 | [diff] [blame] | 202 | metrics_lib_->SendEnumToUMA( |
David Zeuthen | 4e1d149 | 2014-04-25 13:12:27 -0700 | [diff] [blame] | 203 | metric, |
| 204 | static_cast<int>(attempt_result), |
Tianjie Xu | 282aa1f | 2017-09-05 13:42:45 -0700 | [diff] [blame] | 205 | static_cast<int>(metrics::AttemptResult::kNumConstants)); |
David Zeuthen | 4e1d149 | 2014-04-25 13:12:27 -0700 | [diff] [blame] | 206 | } |
| 207 | |
Tianjie Xu | 282aa1f | 2017-09-05 13:42:45 -0700 | [diff] [blame] | 208 | void MetricsReporterOmaha::ReportUpdateAttemptMetrics( |
| 209 | SystemState* system_state, |
David Zeuthen | 33bae49 | 2014-02-25 16:16:18 -0800 | [diff] [blame] | 210 | int attempt_number, |
| 211 | PayloadType payload_type, |
| 212 | base::TimeDelta duration, |
| 213 | base::TimeDelta duration_uptime, |
| 214 | int64_t payload_size, |
Tianjie Xu | 282aa1f | 2017-09-05 13:42:45 -0700 | [diff] [blame] | 215 | metrics::AttemptResult attempt_result, |
Tianjie Xu | 1f93d09 | 2017-10-09 12:13:29 -0700 | [diff] [blame] | 216 | ErrorCode internal_error_code) { |
Tianjie Xu | 98333a8 | 2017-09-22 21:29:29 -0700 | [diff] [blame] | 217 | string metric = metrics::kMetricAttemptNumber; |
Tianjie Xu | 282aa1f | 2017-09-05 13:42:45 -0700 | [diff] [blame] | 218 | LOG(INFO) << "Uploading " << attempt_number << " for metric " << metric; |
Tianjie Xu | 98333a8 | 2017-09-22 21:29:29 -0700 | [diff] [blame] | 219 | metrics_lib_->SendToUMA(metric, |
| 220 | attempt_number, |
| 221 | 0, // min: 0 attempts |
| 222 | 49, // max: 49 attempts |
| 223 | 50); // num_buckets |
David Zeuthen | 33bae49 | 2014-02-25 16:16:18 -0800 | [diff] [blame] | 224 | |
Tianjie Xu | 98333a8 | 2017-09-22 21:29:29 -0700 | [diff] [blame] | 225 | metric = metrics::kMetricAttemptPayloadType; |
Tianjie Xu | 282aa1f | 2017-09-05 13:42:45 -0700 | [diff] [blame] | 226 | LOG(INFO) << "Uploading " << utils::ToString(payload_type) << " for metric " |
| 227 | << metric; |
Tianjie Xu | 98333a8 | 2017-09-22 21:29:29 -0700 | [diff] [blame] | 228 | metrics_lib_->SendEnumToUMA(metric, payload_type, kNumPayloadTypes); |
David Zeuthen | 33bae49 | 2014-02-25 16:16:18 -0800 | [diff] [blame] | 229 | |
Tianjie Xu | 98333a8 | 2017-09-22 21:29:29 -0700 | [diff] [blame] | 230 | metric = metrics::kMetricAttemptDurationMinutes; |
David Zeuthen | 33bae49 | 2014-02-25 16:16:18 -0800 | [diff] [blame] | 231 | LOG(INFO) << "Uploading " << utils::FormatTimeDelta(duration) |
Tianjie Xu | 282aa1f | 2017-09-05 13:42:45 -0700 | [diff] [blame] | 232 | << " for metric " << metric; |
Tianjie Xu | 98333a8 | 2017-09-22 21:29:29 -0700 | [diff] [blame] | 233 | metrics_lib_->SendToUMA(metric, |
| 234 | duration.InMinutes(), |
| 235 | 0, // min: 0 min |
| 236 | 10 * 24 * 60, // max: 10 days |
| 237 | 50); // num_buckets |
David Zeuthen | 33bae49 | 2014-02-25 16:16:18 -0800 | [diff] [blame] | 238 | |
Tianjie Xu | 98333a8 | 2017-09-22 21:29:29 -0700 | [diff] [blame] | 239 | metric = metrics::kMetricAttemptDurationUptimeMinutes; |
David Zeuthen | 33bae49 | 2014-02-25 16:16:18 -0800 | [diff] [blame] | 240 | LOG(INFO) << "Uploading " << utils::FormatTimeDelta(duration_uptime) |
Tianjie Xu | 282aa1f | 2017-09-05 13:42:45 -0700 | [diff] [blame] | 241 | << " for metric " << metric; |
Tianjie Xu | 98333a8 | 2017-09-22 21:29:29 -0700 | [diff] [blame] | 242 | metrics_lib_->SendToUMA(metric, |
| 243 | duration_uptime.InMinutes(), |
| 244 | 0, // min: 0 min |
| 245 | 10 * 24 * 60, // max: 10 days |
| 246 | 50); // num_buckets |
David Zeuthen | 33bae49 | 2014-02-25 16:16:18 -0800 | [diff] [blame] | 247 | |
Tianjie Xu | 98333a8 | 2017-09-22 21:29:29 -0700 | [diff] [blame] | 248 | metric = metrics::kMetricAttemptPayloadSizeMiB; |
David Zeuthen | 33bae49 | 2014-02-25 16:16:18 -0800 | [diff] [blame] | 249 | int64_t payload_size_mib = payload_size / kNumBytesInOneMiB; |
Tianjie Xu | 282aa1f | 2017-09-05 13:42:45 -0700 | [diff] [blame] | 250 | LOG(INFO) << "Uploading " << payload_size_mib << " for metric " << metric; |
Tianjie Xu | 98333a8 | 2017-09-22 21:29:29 -0700 | [diff] [blame] | 251 | metrics_lib_->SendToUMA(metric, |
| 252 | payload_size_mib, |
| 253 | 0, // min: 0 MiB |
| 254 | 1024, // max: 1024 MiB = 1 GiB |
| 255 | 50); // num_buckets |
David Zeuthen | 33bae49 | 2014-02-25 16:16:18 -0800 | [diff] [blame] | 256 | |
David Zeuthen | 33bae49 | 2014-02-25 16:16:18 -0800 | [diff] [blame] | 257 | |
David Zeuthen | 33bae49 | 2014-02-25 16:16:18 -0800 | [diff] [blame] | 258 | |
Tianjie Xu | 98333a8 | 2017-09-22 21:29:29 -0700 | [diff] [blame] | 259 | metric = metrics::kMetricAttemptResult; |
David Zeuthen | 33bae49 | 2014-02-25 16:16:18 -0800 | [diff] [blame] | 260 | LOG(INFO) << "Uploading " << static_cast<int>(attempt_result) |
Tianjie Xu | 282aa1f | 2017-09-05 13:42:45 -0700 | [diff] [blame] | 261 | << " for metric " << metric; |
Tianjie Xu | 98333a8 | 2017-09-22 21:29:29 -0700 | [diff] [blame] | 262 | metrics_lib_->SendEnumToUMA( |
David Zeuthen | 33bae49 | 2014-02-25 16:16:18 -0800 | [diff] [blame] | 263 | metric, |
| 264 | static_cast<int>(attempt_result), |
Tianjie Xu | 282aa1f | 2017-09-05 13:42:45 -0700 | [diff] [blame] | 265 | static_cast<int>(metrics::AttemptResult::kNumConstants)); |
David Zeuthen | 33bae49 | 2014-02-25 16:16:18 -0800 | [diff] [blame] | 266 | |
Gilad Arnold | d1c4d2d | 2014-06-05 14:07:53 -0700 | [diff] [blame] | 267 | if (internal_error_code != ErrorCode::kSuccess) { |
Tianjie Xu | 98333a8 | 2017-09-22 21:29:29 -0700 | [diff] [blame] | 268 | metric = metrics::kMetricAttemptInternalErrorCode; |
Tianjie Xu | 282aa1f | 2017-09-05 13:42:45 -0700 | [diff] [blame] | 269 | LOG(INFO) << "Uploading " << internal_error_code << " for metric " |
| 270 | << metric; |
Tianjie Xu | 98333a8 | 2017-09-22 21:29:29 -0700 | [diff] [blame] | 271 | metrics_lib_->SendEnumToUMA(metric, |
| 272 | static_cast<int>(internal_error_code), |
| 273 | static_cast<int>(ErrorCode::kUmaReportedMax)); |
David Zeuthen | 33bae49 | 2014-02-25 16:16:18 -0800 | [diff] [blame] | 274 | } |
| 275 | |
David Zeuthen | 33bae49 | 2014-02-25 16:16:18 -0800 | [diff] [blame] | 276 | base::TimeDelta time_since_last; |
Alex Deymo | a259179 | 2015-11-17 00:39:40 -0300 | [diff] [blame] | 277 | if (metrics_utils::WallclockDurationHelper( |
| 278 | system_state, |
| 279 | kPrefsMetricsAttemptLastReportingTime, |
| 280 | &time_since_last)) { |
Tianjie Xu | 98333a8 | 2017-09-22 21:29:29 -0700 | [diff] [blame] | 281 | metric = metrics::kMetricAttemptTimeSinceLastAttemptMinutes; |
David Zeuthen | 33bae49 | 2014-02-25 16:16:18 -0800 | [diff] [blame] | 282 | LOG(INFO) << "Sending " << utils::FormatTimeDelta(time_since_last) |
| 283 | << " for metric " << metric; |
Tianjie Xu | 98333a8 | 2017-09-22 21:29:29 -0700 | [diff] [blame] | 284 | metrics_lib_->SendToUMA(metric, |
| 285 | time_since_last.InMinutes(), |
| 286 | 0, // min: 0 min |
| 287 | 30 * 24 * 60, // max: 30 days |
| 288 | 50); // num_buckets |
David Zeuthen | 33bae49 | 2014-02-25 16:16:18 -0800 | [diff] [blame] | 289 | } |
| 290 | |
| 291 | static int64_t uptime_since_last_storage = 0; |
| 292 | base::TimeDelta uptime_since_last; |
Tianjie Xu | 282aa1f | 2017-09-05 13:42:45 -0700 | [diff] [blame] | 293 | if (metrics_utils::MonotonicDurationHelper( |
| 294 | system_state, &uptime_since_last_storage, &uptime_since_last)) { |
Tianjie Xu | 98333a8 | 2017-09-22 21:29:29 -0700 | [diff] [blame] | 295 | metric = metrics::kMetricAttemptTimeSinceLastAttemptUptimeMinutes; |
David Zeuthen | 33bae49 | 2014-02-25 16:16:18 -0800 | [diff] [blame] | 296 | LOG(INFO) << "Sending " << utils::FormatTimeDelta(uptime_since_last) |
| 297 | << " for metric " << metric; |
Tianjie Xu | 98333a8 | 2017-09-22 21:29:29 -0700 | [diff] [blame] | 298 | metrics_lib_->SendToUMA(metric, |
| 299 | uptime_since_last.InMinutes(), |
| 300 | 0, // min: 0 min |
| 301 | 30 * 24 * 60, // max: 30 days |
| 302 | 50); // num_buckets |
David Zeuthen | 33bae49 | 2014-02-25 16:16:18 -0800 | [diff] [blame] | 303 | } |
Tianjie Xu | 1f93d09 | 2017-10-09 12:13:29 -0700 | [diff] [blame] | 304 | } |
| 305 | |
| 306 | void MetricsReporterOmaha::ReportUpdateAttemptDownloadMetrics( |
| 307 | int64_t payload_bytes_downloaded, |
| 308 | int64_t payload_download_speed_bps, |
| 309 | DownloadSource download_source, |
| 310 | metrics::DownloadErrorCode payload_download_error_code, |
| 311 | metrics::ConnectionType connection_type) { |
| 312 | string metric = metrics::kMetricAttemptPayloadBytesDownloadedMiB; |
| 313 | int64_t payload_bytes_downloaded_mib = |
| 314 | payload_bytes_downloaded / kNumBytesInOneMiB; |
| 315 | LOG(INFO) << "Uploading " << payload_bytes_downloaded_mib << " for metric " |
| 316 | << metric; |
| 317 | metrics_lib_->SendToUMA(metric, |
| 318 | payload_bytes_downloaded_mib, |
| 319 | 0, // min: 0 MiB |
| 320 | 1024, // max: 1024 MiB = 1 GiB |
| 321 | 50); // num_buckets |
| 322 | |
| 323 | metric = metrics::kMetricAttemptPayloadDownloadSpeedKBps; |
| 324 | int64_t payload_download_speed_kbps = payload_download_speed_bps / 1000; |
| 325 | LOG(INFO) << "Uploading " << payload_download_speed_kbps << " for metric " |
| 326 | << metric; |
| 327 | metrics_lib_->SendToUMA(metric, |
| 328 | payload_download_speed_kbps, |
| 329 | 0, // min: 0 kB/s |
| 330 | 10 * 1000, // max: 10000 kB/s = 10 MB/s |
| 331 | 50); // num_buckets |
| 332 | |
| 333 | metric = metrics::kMetricAttemptDownloadSource; |
| 334 | LOG(INFO) << "Uploading " << download_source << " for metric " << metric; |
| 335 | metrics_lib_->SendEnumToUMA(metric, download_source, kNumDownloadSources); |
| 336 | |
| 337 | if (payload_download_error_code != metrics::DownloadErrorCode::kUnset) { |
| 338 | metric = metrics::kMetricAttemptDownloadErrorCode; |
| 339 | LOG(INFO) << "Uploading " << static_cast<int>(payload_download_error_code) |
| 340 | << " for metric " << metric << " (sparse)"; |
| 341 | metrics_lib_->SendSparseToUMA( |
| 342 | metric, static_cast<int>(payload_download_error_code)); |
| 343 | } |
David Zeuthen | b281f07 | 2014-04-02 10:20:19 -0700 | [diff] [blame] | 344 | |
Tianjie Xu | 98333a8 | 2017-09-22 21:29:29 -0700 | [diff] [blame] | 345 | metric = metrics::kMetricAttemptConnectionType; |
David Zeuthen | b281f07 | 2014-04-02 10:20:19 -0700 | [diff] [blame] | 346 | LOG(INFO) << "Uploading " << static_cast<int>(connection_type) |
Tianjie Xu | 282aa1f | 2017-09-05 13:42:45 -0700 | [diff] [blame] | 347 | << " for metric " << metric; |
Tianjie Xu | 98333a8 | 2017-09-22 21:29:29 -0700 | [diff] [blame] | 348 | metrics_lib_->SendEnumToUMA( |
David Zeuthen | b281f07 | 2014-04-02 10:20:19 -0700 | [diff] [blame] | 349 | metric, |
| 350 | static_cast<int>(connection_type), |
Tianjie Xu | 282aa1f | 2017-09-05 13:42:45 -0700 | [diff] [blame] | 351 | static_cast<int>(metrics::ConnectionType::kNumConstants)); |
David Zeuthen | 33bae49 | 2014-02-25 16:16:18 -0800 | [diff] [blame] | 352 | } |
| 353 | |
Tianjie Xu | 282aa1f | 2017-09-05 13:42:45 -0700 | [diff] [blame] | 354 | void MetricsReporterOmaha::ReportSuccessfulUpdateMetrics( |
| 355 | int attempt_count, |
| 356 | int updates_abandoned_count, |
| 357 | PayloadType payload_type, |
| 358 | int64_t payload_size, |
| 359 | int64_t num_bytes_downloaded[kNumDownloadSources], |
| 360 | int download_overhead_percentage, |
| 361 | base::TimeDelta total_duration, |
| 362 | int reboot_count, |
| 363 | int url_switch_count) { |
Tianjie Xu | 98333a8 | 2017-09-22 21:29:29 -0700 | [diff] [blame] | 364 | string metric = metrics::kMetricSuccessfulUpdatePayloadSizeMiB; |
Tianjie Xu | 282aa1f | 2017-09-05 13:42:45 -0700 | [diff] [blame] | 365 | int64_t mbs = payload_size / kNumBytesInOneMiB; |
David Zeuthen | 33bae49 | 2014-02-25 16:16:18 -0800 | [diff] [blame] | 366 | LOG(INFO) << "Uploading " << mbs << " (MiBs) for metric " << metric; |
Tianjie Xu | 98333a8 | 2017-09-22 21:29:29 -0700 | [diff] [blame] | 367 | metrics_lib_->SendToUMA(metric, |
| 368 | mbs, |
| 369 | 0, // min: 0 MiB |
| 370 | 1024, // max: 1024 MiB = 1 GiB |
| 371 | 50); // num_buckets |
David Zeuthen | 33bae49 | 2014-02-25 16:16:18 -0800 | [diff] [blame] | 372 | |
| 373 | int64_t total_bytes = 0; |
| 374 | int download_sources_used = 0; |
| 375 | for (int i = 0; i < kNumDownloadSources + 1; i++) { |
| 376 | DownloadSource source = static_cast<DownloadSource>(i); |
| 377 | |
| 378 | // Only consider this download source (and send byte counts) as |
| 379 | // having been used if we downloaded a non-trivial amount of bytes |
Alex Vakulenko | 072359c | 2014-07-18 11:41:07 -0700 | [diff] [blame] | 380 | // (e.g. at least 1 MiB) that contributed to the |
David Zeuthen | 33bae49 | 2014-02-25 16:16:18 -0800 | [diff] [blame] | 381 | // update. Otherwise we're going to end up with a lot of zero-byte |
| 382 | // events in the histogram. |
| 383 | |
Tianjie Xu | 98333a8 | 2017-09-22 21:29:29 -0700 | [diff] [blame] | 384 | metric = metrics::kMetricSuccessfulUpdateBytesDownloadedMiB; |
David Zeuthen | 33bae49 | 2014-02-25 16:16:18 -0800 | [diff] [blame] | 385 | if (i < kNumDownloadSources) { |
| 386 | metric += utils::ToString(source); |
| 387 | mbs = num_bytes_downloaded[i] / kNumBytesInOneMiB; |
| 388 | total_bytes += num_bytes_downloaded[i]; |
| 389 | if (mbs > 0) |
| 390 | download_sources_used |= (1 << i); |
| 391 | } else { |
| 392 | mbs = total_bytes / kNumBytesInOneMiB; |
| 393 | } |
| 394 | |
| 395 | if (mbs > 0) { |
| 396 | LOG(INFO) << "Uploading " << mbs << " (MiBs) for metric " << metric; |
Tianjie Xu | 98333a8 | 2017-09-22 21:29:29 -0700 | [diff] [blame] | 397 | metrics_lib_->SendToUMA(metric, |
| 398 | mbs, |
| 399 | 0, // min: 0 MiB |
| 400 | 1024, // max: 1024 MiB = 1 GiB |
| 401 | 50); // num_buckets |
David Zeuthen | 33bae49 | 2014-02-25 16:16:18 -0800 | [diff] [blame] | 402 | } |
| 403 | } |
| 404 | |
Tianjie Xu | 98333a8 | 2017-09-22 21:29:29 -0700 | [diff] [blame] | 405 | metric = metrics::kMetricSuccessfulUpdateDownloadSourcesUsed; |
David Zeuthen | 33bae49 | 2014-02-25 16:16:18 -0800 | [diff] [blame] | 406 | LOG(INFO) << "Uploading 0x" << std::hex << download_sources_used |
| 407 | << " (bit flags) for metric " << metric; |
Tianjie Xu | 98333a8 | 2017-09-22 21:29:29 -0700 | [diff] [blame] | 408 | metrics_lib_->SendToUMA(metric, |
| 409 | download_sources_used, |
| 410 | 0, // min |
| 411 | (1 << kNumDownloadSources) - 1, // max |
| 412 | 1 << kNumDownloadSources); // num_buckets |
David Zeuthen | 33bae49 | 2014-02-25 16:16:18 -0800 | [diff] [blame] | 413 | |
Tianjie Xu | 98333a8 | 2017-09-22 21:29:29 -0700 | [diff] [blame] | 414 | metric = metrics::kMetricSuccessfulUpdateDownloadOverheadPercentage; |
Tianjie Xu | 282aa1f | 2017-09-05 13:42:45 -0700 | [diff] [blame] | 415 | LOG(INFO) << "Uploading " << download_overhead_percentage << "% for metric " |
| 416 | << metric; |
Tianjie Xu | 98333a8 | 2017-09-22 21:29:29 -0700 | [diff] [blame] | 417 | metrics_lib_->SendToUMA(metric, |
| 418 | download_overhead_percentage, |
| 419 | 0, // min: 0% overhead |
| 420 | 1000, // max: 1000% overhead |
| 421 | 50); // num_buckets |
David Zeuthen | 33bae49 | 2014-02-25 16:16:18 -0800 | [diff] [blame] | 422 | |
Tianjie Xu | 98333a8 | 2017-09-22 21:29:29 -0700 | [diff] [blame] | 423 | metric = metrics::kMetricSuccessfulUpdateUrlSwitchCount; |
Tianjie Xu | 282aa1f | 2017-09-05 13:42:45 -0700 | [diff] [blame] | 424 | LOG(INFO) << "Uploading " << url_switch_count << " (count) for metric " |
| 425 | << metric; |
Tianjie Xu | 98333a8 | 2017-09-22 21:29:29 -0700 | [diff] [blame] | 426 | metrics_lib_->SendToUMA(metric, |
| 427 | url_switch_count, |
| 428 | 0, // min: 0 URL switches |
| 429 | 49, // max: 49 URL switches |
| 430 | 50); // num_buckets |
David Zeuthen | 33bae49 | 2014-02-25 16:16:18 -0800 | [diff] [blame] | 431 | |
Tianjie Xu | 98333a8 | 2017-09-22 21:29:29 -0700 | [diff] [blame] | 432 | metric = metrics::kMetricSuccessfulUpdateTotalDurationMinutes; |
David Zeuthen | 33bae49 | 2014-02-25 16:16:18 -0800 | [diff] [blame] | 433 | LOG(INFO) << "Uploading " << utils::FormatTimeDelta(total_duration) |
Tianjie Xu | 282aa1f | 2017-09-05 13:42:45 -0700 | [diff] [blame] | 434 | << " for metric " << metric; |
Tianjie Xu | 98333a8 | 2017-09-22 21:29:29 -0700 | [diff] [blame] | 435 | metrics_lib_->SendToUMA(metric, |
| 436 | static_cast<int>(total_duration.InMinutes()), |
| 437 | 0, // min: 0 min |
| 438 | 365 * 24 * 60, // max: 365 days ~= 1 year |
| 439 | 50); // num_buckets |
David Zeuthen | 33bae49 | 2014-02-25 16:16:18 -0800 | [diff] [blame] | 440 | |
Tianjie Xu | 98333a8 | 2017-09-22 21:29:29 -0700 | [diff] [blame] | 441 | metric = metrics::kMetricSuccessfulUpdateRebootCount; |
David Zeuthen | 33bae49 | 2014-02-25 16:16:18 -0800 | [diff] [blame] | 442 | LOG(INFO) << "Uploading reboot count of " << reboot_count << " for metric " |
Tianjie Xu | 282aa1f | 2017-09-05 13:42:45 -0700 | [diff] [blame] | 443 | << metric; |
Tianjie Xu | 98333a8 | 2017-09-22 21:29:29 -0700 | [diff] [blame] | 444 | metrics_lib_->SendToUMA(metric, |
| 445 | reboot_count, |
| 446 | 0, // min: 0 reboots |
| 447 | 49, // max: 49 reboots |
| 448 | 50); // num_buckets |
David Zeuthen | 33bae49 | 2014-02-25 16:16:18 -0800 | [diff] [blame] | 449 | |
Tianjie Xu | 98333a8 | 2017-09-22 21:29:29 -0700 | [diff] [blame] | 450 | metric = metrics::kMetricSuccessfulUpdatePayloadType; |
| 451 | metrics_lib_->SendEnumToUMA(metric, payload_type, kNumPayloadTypes); |
Tianjie Xu | 282aa1f | 2017-09-05 13:42:45 -0700 | [diff] [blame] | 452 | LOG(INFO) << "Uploading " << utils::ToString(payload_type) << " for metric " |
| 453 | << metric; |
David Zeuthen | 33bae49 | 2014-02-25 16:16:18 -0800 | [diff] [blame] | 454 | |
Tianjie Xu | 98333a8 | 2017-09-22 21:29:29 -0700 | [diff] [blame] | 455 | metric = metrics::kMetricSuccessfulUpdateAttemptCount; |
| 456 | metrics_lib_->SendToUMA(metric, |
| 457 | attempt_count, |
| 458 | 1, // min: 1 attempt |
| 459 | 50, // max: 50 attempts |
| 460 | 50); // num_buckets |
Tianjie Xu | 282aa1f | 2017-09-05 13:42:45 -0700 | [diff] [blame] | 461 | LOG(INFO) << "Uploading " << attempt_count << " for metric " << metric; |
David Zeuthen | 33bae49 | 2014-02-25 16:16:18 -0800 | [diff] [blame] | 462 | |
Tianjie Xu | 98333a8 | 2017-09-22 21:29:29 -0700 | [diff] [blame] | 463 | metric = metrics::kMetricSuccessfulUpdateUpdatesAbandonedCount; |
Tianjie Xu | 282aa1f | 2017-09-05 13:42:45 -0700 | [diff] [blame] | 464 | LOG(INFO) << "Uploading " << updates_abandoned_count << " (count) for metric " |
| 465 | << metric; |
Tianjie Xu | 98333a8 | 2017-09-22 21:29:29 -0700 | [diff] [blame] | 466 | metrics_lib_->SendToUMA(metric, |
| 467 | updates_abandoned_count, |
| 468 | 0, // min: 0 counts |
| 469 | 49, // max: 49 counts |
| 470 | 50); // num_buckets |
David Zeuthen | 33bae49 | 2014-02-25 16:16:18 -0800 | [diff] [blame] | 471 | } |
| 472 | |
Tianjie Xu | 282aa1f | 2017-09-05 13:42:45 -0700 | [diff] [blame] | 473 | void MetricsReporterOmaha::ReportRollbackMetrics( |
| 474 | metrics::RollbackResult result) { |
Tianjie Xu | 98333a8 | 2017-09-22 21:29:29 -0700 | [diff] [blame] | 475 | string metric = metrics::kMetricRollbackResult; |
Tianjie Xu | 282aa1f | 2017-09-05 13:42:45 -0700 | [diff] [blame] | 476 | int value = static_cast<int>(result); |
David Zeuthen | 96197df | 2014-04-16 12:22:39 -0700 | [diff] [blame] | 477 | LOG(INFO) << "Sending " << value << " for metric " << metric << " (enum)"; |
Tianjie Xu | 98333a8 | 2017-09-22 21:29:29 -0700 | [diff] [blame] | 478 | metrics_lib_->SendEnumToUMA( |
Tianjie Xu | 282aa1f | 2017-09-05 13:42:45 -0700 | [diff] [blame] | 479 | metric, value, static_cast<int>(metrics::RollbackResult::kNumConstants)); |
David Zeuthen | 96197df | 2014-04-16 12:22:39 -0700 | [diff] [blame] | 480 | } |
| 481 | |
Tianjie Xu | 282aa1f | 2017-09-05 13:42:45 -0700 | [diff] [blame] | 482 | void MetricsReporterOmaha::ReportCertificateCheckMetrics( |
| 483 | ServerToCheck server_to_check, CertificateCheckResult result) { |
Alex Deymo | c1c17b4 | 2015-11-23 03:53:15 -0300 | [diff] [blame] | 484 | string metric; |
| 485 | switch (server_to_check) { |
| 486 | case ServerToCheck::kUpdate: |
Tianjie Xu | 98333a8 | 2017-09-22 21:29:29 -0700 | [diff] [blame] | 487 | metric = metrics::kMetricCertificateCheckUpdateCheck; |
Alex Deymo | c1c17b4 | 2015-11-23 03:53:15 -0300 | [diff] [blame] | 488 | break; |
| 489 | case ServerToCheck::kDownload: |
Tianjie Xu | 98333a8 | 2017-09-22 21:29:29 -0700 | [diff] [blame] | 490 | metric = metrics::kMetricCertificateCheckDownload; |
Alex Deymo | c1c17b4 | 2015-11-23 03:53:15 -0300 | [diff] [blame] | 491 | break; |
Alex Deymo | 33e91e7 | 2015-12-01 18:26:08 -0300 | [diff] [blame] | 492 | case ServerToCheck::kNone: |
| 493 | return; |
Alex Deymo | c1c17b4 | 2015-11-23 03:53:15 -0300 | [diff] [blame] | 494 | } |
| 495 | LOG(INFO) << "Uploading " << static_cast<int>(result) << " for metric " |
| 496 | << metric; |
Tianjie Xu | 98333a8 | 2017-09-22 21:29:29 -0700 | [diff] [blame] | 497 | metrics_lib_->SendEnumToUMA( |
Tianjie Xu | 282aa1f | 2017-09-05 13:42:45 -0700 | [diff] [blame] | 498 | metric, |
| 499 | static_cast<int>(result), |
Alex Deymo | c1c17b4 | 2015-11-23 03:53:15 -0300 | [diff] [blame] | 500 | static_cast<int>(CertificateCheckResult::kNumConstants)); |
| 501 | } |
| 502 | |
Tianjie Xu | 282aa1f | 2017-09-05 13:42:45 -0700 | [diff] [blame] | 503 | void MetricsReporterOmaha::ReportFailedUpdateCount(int target_attempt) { |
Tianjie Xu | 98333a8 | 2017-09-22 21:29:29 -0700 | [diff] [blame] | 504 | string metric = metrics::kMetricFailedUpdateCount; |
| 505 | metrics_lib_->SendToUMA(metric, |
| 506 | target_attempt, |
| 507 | 1, // min value |
| 508 | 50, // max value |
| 509 | kNumDefaultUmaBuckets); |
Tianjie Xu | 282aa1f | 2017-09-05 13:42:45 -0700 | [diff] [blame] | 510 | |
| 511 | LOG(INFO) << "Uploading " << target_attempt << " (count) for metric " |
| 512 | << metric; |
| 513 | } |
| 514 | |
| 515 | void MetricsReporterOmaha::ReportTimeToReboot(int time_to_reboot_minutes) { |
Tianjie Xu | 98333a8 | 2017-09-22 21:29:29 -0700 | [diff] [blame] | 516 | string metric = metrics::kMetricTimeToRebootMinutes; |
| 517 | metrics_lib_->SendToUMA(metric, |
| 518 | time_to_reboot_minutes, |
| 519 | 0, // min: 0 minute |
| 520 | 30 * 24 * 60, // max: 1 month (approx) |
| 521 | kNumDefaultUmaBuckets); |
Tianjie Xu | 282aa1f | 2017-09-05 13:42:45 -0700 | [diff] [blame] | 522 | |
| 523 | LOG(INFO) << "Uploading " << time_to_reboot_minutes << " for metric " |
| 524 | << metric; |
| 525 | } |
| 526 | |
| 527 | void MetricsReporterOmaha::ReportInstallDateProvisioningSource(int source, |
| 528 | int max) { |
Tianjie Xu | 98333a8 | 2017-09-22 21:29:29 -0700 | [diff] [blame] | 529 | metrics_lib_->SendEnumToUMA(metrics::kMetricInstallDateProvisioningSource, |
| 530 | source, // Sample. |
| 531 | max); |
Tianjie Xu | 282aa1f | 2017-09-05 13:42:45 -0700 | [diff] [blame] | 532 | } |
David Zeuthen | 33bae49 | 2014-02-25 16:16:18 -0800 | [diff] [blame] | 533 | |
| 534 | } // namespace chromeos_update_engine |