Tianjie Xu | 282aa1f | 2017-09-05 13:42:45 -0700 | [diff] [blame] | 1 | // |
| 2 | // Copyright (C) 2017 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 | // |
| 16 | |
| 17 | #ifndef UPDATE_ENGINE_METRICS_REPORTER_OMAHA_H_ |
| 18 | #define UPDATE_ENGINE_METRICS_REPORTER_OMAHA_H_ |
| 19 | |
Tianjie Xu | 98333a8 | 2017-09-22 21:29:29 -0700 | [diff] [blame] | 20 | #include <memory> |
Marton Hunyady | a030268 | 2018-05-16 18:52:13 +0200 | [diff] [blame] | 21 | #include <string> |
Tianjie Xu | 98333a8 | 2017-09-22 21:29:29 -0700 | [diff] [blame] | 22 | |
Tianjie Xu | 282aa1f | 2017-09-05 13:42:45 -0700 | [diff] [blame] | 23 | #include <base/time/time.h> |
| 24 | #include <metrics/metrics_library.h> |
| 25 | |
| 26 | #include "update_engine/certificate_checker.h" |
| 27 | #include "update_engine/common/constants.h" |
| 28 | #include "update_engine/common/error_code.h" |
| 29 | #include "update_engine/metrics_constants.h" |
| 30 | #include "update_engine/metrics_reporter_interface.h" |
| 31 | #include "update_engine/system_state.h" |
| 32 | |
| 33 | namespace chromeos_update_engine { |
| 34 | |
| 35 | class SystemState; |
| 36 | |
Tianjie Xu | 98333a8 | 2017-09-22 21:29:29 -0700 | [diff] [blame] | 37 | namespace metrics { |
| 38 | |
| 39 | // UpdateEngine.Daily.* metrics. |
| 40 | extern const char kMetricDailyOSAgeDays[]; |
| 41 | |
| 42 | // UpdateEngine.Check.* metrics. |
| 43 | extern const char kMetricCheckDownloadErrorCode[]; |
| 44 | extern const char kMetricCheckReaction[]; |
| 45 | extern const char kMetricCheckResult[]; |
Marton Hunyady | a030268 | 2018-05-16 18:52:13 +0200 | [diff] [blame] | 46 | extern const char kMetricCheckTargetVersion[]; |
| 47 | extern const char kMetricCheckRollbackTargetVersion[]; |
Tianjie Xu | 98333a8 | 2017-09-22 21:29:29 -0700 | [diff] [blame] | 48 | extern const char kMetricCheckTimeSinceLastCheckMinutes[]; |
| 49 | extern const char kMetricCheckTimeSinceLastCheckUptimeMinutes[]; |
| 50 | |
| 51 | // UpdateEngine.Attempt.* metrics. |
| 52 | extern const char kMetricAttemptNumber[]; |
| 53 | extern const char kMetricAttemptPayloadType[]; |
| 54 | extern const char kMetricAttemptPayloadSizeMiB[]; |
| 55 | extern const char kMetricAttemptConnectionType[]; |
| 56 | extern const char kMetricAttemptDurationMinutes[]; |
| 57 | extern const char kMetricAttemptDurationUptimeMinutes[]; |
| 58 | extern const char kMetricAttemptTimeSinceLastAttemptMinutes[]; |
| 59 | extern const char kMetricAttemptTimeSinceLastAttemptUptimeMinutes[]; |
| 60 | extern const char kMetricAttemptPayloadBytesDownloadedMiB[]; |
| 61 | extern const char kMetricAttemptPayloadDownloadSpeedKBps[]; |
| 62 | extern const char kMetricAttemptDownloadSource[]; |
| 63 | extern const char kMetricAttemptResult[]; |
| 64 | extern const char kMetricAttemptInternalErrorCode[]; |
| 65 | extern const char kMetricAttemptDownloadErrorCode[]; |
| 66 | |
| 67 | // UpdateEngine.SuccessfulUpdate.* metrics. |
| 68 | extern const char kMetricSuccessfulUpdateAttemptCount[]; |
| 69 | extern const char kMetricSuccessfulUpdateBytesDownloadedMiB[]; |
| 70 | extern const char kMetricSuccessfulUpdateDownloadOverheadPercentage[]; |
| 71 | extern const char kMetricSuccessfulUpdateDownloadSourcesUsed[]; |
May Lippert | 60aa3ca | 2018-08-15 16:55:29 -0700 | [diff] [blame] | 72 | extern const char kMetricSuccessfulUpdateDurationFromSeenDays[]; |
| 73 | extern const char kMetricSuccessfulUpdateDurationFromSeenTimeRestrictedDays[]; |
Tianjie Xu | 98333a8 | 2017-09-22 21:29:29 -0700 | [diff] [blame] | 74 | extern const char kMetricSuccessfulUpdatePayloadType[]; |
| 75 | extern const char kMetricSuccessfulUpdatePayloadSizeMiB[]; |
| 76 | extern const char kMetricSuccessfulUpdateRebootCount[]; |
| 77 | extern const char kMetricSuccessfulUpdateTotalDurationMinutes[]; |
Sen Jiang | 8712e96 | 2018-05-08 12:12:28 -0700 | [diff] [blame] | 78 | extern const char kMetricSuccessfulUpdateTotalDurationUptimeMinutes[]; |
Tianjie Xu | 98333a8 | 2017-09-22 21:29:29 -0700 | [diff] [blame] | 79 | extern const char kMetricSuccessfulUpdateUpdatesAbandonedCount[]; |
| 80 | extern const char kMetricSuccessfulUpdateUrlSwitchCount[]; |
| 81 | |
| 82 | // UpdateEngine.Rollback.* metric. |
| 83 | extern const char kMetricRollbackResult[]; |
| 84 | |
Marton Hunyady | a030268 | 2018-05-16 18:52:13 +0200 | [diff] [blame] | 85 | // UpdateEngine.EnterpriseRollback.* metrics. |
| 86 | extern const char kMetricEnterpriseRollbackFailure[]; |
| 87 | extern const char kMetricEnterpriseRollbackSuccess[]; |
| 88 | |
Tianjie Xu | 98333a8 | 2017-09-22 21:29:29 -0700 | [diff] [blame] | 89 | // UpdateEngine.CertificateCheck.* metrics. |
| 90 | extern const char kMetricCertificateCheckUpdateCheck[]; |
| 91 | extern const char kMetricCertificateCheckDownload[]; |
| 92 | |
Marton Hunyady | ffbfdfb | 2018-05-30 13:03:29 +0200 | [diff] [blame] | 93 | // UpdateEngine.KernelKey.* metrics. |
| 94 | extern const char kMetricKernelMinVersion[]; |
| 95 | extern const char kMetricKernelMaxRollforwardVersion[]; |
| 96 | extern const char kMetricKernelMaxRollforwardSetSuccess[]; |
| 97 | |
Tianjie Xu | 98333a8 | 2017-09-22 21:29:29 -0700 | [diff] [blame] | 98 | // UpdateEngine.* metrics. |
| 99 | extern const char kMetricFailedUpdateCount[]; |
| 100 | extern const char kMetricInstallDateProvisioningSource[]; |
| 101 | extern const char kMetricTimeToRebootMinutes[]; |
| 102 | |
| 103 | } // namespace metrics |
| 104 | |
Tianjie Xu | 282aa1f | 2017-09-05 13:42:45 -0700 | [diff] [blame] | 105 | class MetricsReporterOmaha : public MetricsReporterInterface { |
| 106 | public: |
Tianjie Xu | 98333a8 | 2017-09-22 21:29:29 -0700 | [diff] [blame] | 107 | MetricsReporterOmaha(); |
Tianjie Xu | 282aa1f | 2017-09-05 13:42:45 -0700 | [diff] [blame] | 108 | |
| 109 | ~MetricsReporterOmaha() override = default; |
| 110 | |
Tianjie Xu | 282aa1f | 2017-09-05 13:42:45 -0700 | [diff] [blame] | 111 | void ReportRollbackMetrics(metrics::RollbackResult result) override; |
| 112 | |
Marton Hunyady | a030268 | 2018-05-16 18:52:13 +0200 | [diff] [blame] | 113 | void ReportEnterpriseRollbackMetrics( |
| 114 | bool success, const std::string& rollback_version) override; |
| 115 | |
Tianjie Xu | 282aa1f | 2017-09-05 13:42:45 -0700 | [diff] [blame] | 116 | void ReportDailyMetrics(base::TimeDelta os_age) override; |
| 117 | |
| 118 | void ReportUpdateCheckMetrics( |
| 119 | SystemState* system_state, |
| 120 | metrics::CheckResult result, |
| 121 | metrics::CheckReaction reaction, |
| 122 | metrics::DownloadErrorCode download_error_code) override; |
| 123 | |
Tianjie Xu | 1f93d09 | 2017-10-09 12:13:29 -0700 | [diff] [blame] | 124 | void ReportUpdateAttemptMetrics(SystemState* system_state, |
| 125 | int attempt_number, |
| 126 | PayloadType payload_type, |
| 127 | base::TimeDelta duration, |
| 128 | base::TimeDelta duration_uptime, |
| 129 | int64_t payload_size, |
| 130 | metrics::AttemptResult attempt_result, |
| 131 | ErrorCode internal_error_code) override; |
| 132 | |
| 133 | void ReportUpdateAttemptDownloadMetrics( |
Tianjie Xu | 282aa1f | 2017-09-05 13:42:45 -0700 | [diff] [blame] | 134 | int64_t payload_bytes_downloaded, |
| 135 | int64_t payload_download_speed_bps, |
| 136 | DownloadSource download_source, |
Tianjie Xu | 282aa1f | 2017-09-05 13:42:45 -0700 | [diff] [blame] | 137 | metrics::DownloadErrorCode payload_download_error_code, |
| 138 | metrics::ConnectionType connection_type) override; |
| 139 | |
| 140 | void ReportAbnormallyTerminatedUpdateAttemptMetrics() override; |
| 141 | |
| 142 | void ReportSuccessfulUpdateMetrics( |
| 143 | int attempt_count, |
| 144 | int updates_abandoned_count, |
| 145 | PayloadType payload_type, |
| 146 | int64_t payload_size, |
| 147 | int64_t num_bytes_downloaded[kNumDownloadSources], |
| 148 | int download_overhead_percentage, |
| 149 | base::TimeDelta total_duration, |
Sen Jiang | 8712e96 | 2018-05-08 12:12:28 -0700 | [diff] [blame] | 150 | base::TimeDelta total_duration_uptime, |
Tianjie Xu | 282aa1f | 2017-09-05 13:42:45 -0700 | [diff] [blame] | 151 | int reboot_count, |
| 152 | int url_switch_count) override; |
| 153 | |
| 154 | void ReportCertificateCheckMetrics(ServerToCheck server_to_check, |
| 155 | CertificateCheckResult result) override; |
| 156 | |
| 157 | void ReportFailedUpdateCount(int target_attempt) override; |
| 158 | |
| 159 | void ReportTimeToReboot(int time_to_reboot_minutes) override; |
| 160 | |
| 161 | void ReportInstallDateProvisioningSource(int source, int max) override; |
| 162 | |
Amin Hassani | 80f4d4c | 2018-05-16 13:34:00 -0700 | [diff] [blame] | 163 | void ReportInternalErrorCode(ErrorCode error_code) override; |
| 164 | |
Marton Hunyady | ffbfdfb | 2018-05-30 13:03:29 +0200 | [diff] [blame] | 165 | void ReportKeyVersionMetrics(int kernel_min_version, |
| 166 | int kernel_max_rollforward_version, |
| 167 | bool kernel_max_rollforward_success) override; |
| 168 | |
May Lippert | 60aa3ca | 2018-08-15 16:55:29 -0700 | [diff] [blame] | 169 | void ReportEnterpriseUpdateSeenToDownloadDays( |
| 170 | bool has_time_restriction_policy, int time_to_update_days) override; |
| 171 | |
Tianjie Xu | 282aa1f | 2017-09-05 13:42:45 -0700 | [diff] [blame] | 172 | private: |
Tianjie Xu | 98333a8 | 2017-09-22 21:29:29 -0700 | [diff] [blame] | 173 | friend class MetricsReporterOmahaTest; |
| 174 | |
| 175 | std::unique_ptr<MetricsLibraryInterface> metrics_lib_; |
Tianjie Xu | 282aa1f | 2017-09-05 13:42:45 -0700 | [diff] [blame] | 176 | |
| 177 | DISALLOW_COPY_AND_ASSIGN(MetricsReporterOmaha); |
| 178 | }; // class metrics |
| 179 | |
| 180 | } // namespace chromeos_update_engine |
| 181 | |
| 182 | #endif // UPDATE_ENGINE_METRICS_REPORTER_OMAHA_H_ |