blob: 0c8a025d9b49ac0944be0ab8e340094ef47fe17e [file] [log] [blame]
Tianjie Xu282aa1f2017-09-05 13:42:45 -07001//
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_INTERFACE_H_
18#define UPDATE_ENGINE_METRICS_REPORTER_INTERFACE_H_
19
20#include <base/time/time.h>
21
Tianjie Xu282aa1f2017-09-05 13:42:45 -070022#include "update_engine/common/constants.h"
23#include "update_engine/common/error_code.h"
24#include "update_engine/metrics_constants.h"
25#include "update_engine/system_state.h"
26
27namespace chromeos_update_engine {
28
Tianjie Xu1b661142017-09-28 14:03:42 -070029enum class ServerToCheck;
30enum class CertificateCheckResult;
31
Tianjie Xu282aa1f2017-09-05 13:42:45 -070032class MetricsReporterInterface {
33 public:
34 virtual ~MetricsReporterInterface() = default;
35
36 virtual void Initialize() = 0;
37
38 // Helper function to report metrics related to rollback. The
39 // following metrics are reported:
40 //
41 // |kMetricRollbackResult|
42 virtual void ReportRollbackMetrics(metrics::RollbackResult result) = 0;
43
44 // Helper function to report metrics reported once a day. The
45 // following metrics are reported:
46 //
47 // |kMetricDailyOSAgeDays|
48 virtual void ReportDailyMetrics(base::TimeDelta os_age) = 0;
49
50 // Helper function to report metrics after completing an update check
51 // with the ChromeOS update server ("Omaha"). The following metrics
52 // are reported:
53 //
54 // |kMetricCheckResult|
55 // |kMetricCheckReaction|
56 // |kMetricCheckDownloadErrorCode|
57 // |kMetricCheckTimeSinceLastCheckMinutes|
58 // |kMetricCheckTimeSinceLastCheckUptimeMinutes|
59 //
60 // The |kMetricCheckResult| metric will only be reported if |result|
61 // is not |kUnset|.
62 //
63 // The |kMetricCheckReaction| metric will only be reported if
64 // |reaction| is not |kUnset|.
65 //
66 // The |kMetricCheckDownloadErrorCode| will only be reported if
67 // |download_error_code| is not |kUnset|.
68 //
69 // The values for the |kMetricCheckTimeSinceLastCheckMinutes| and
70 // |kMetricCheckTimeSinceLastCheckUptimeMinutes| metrics are
71 // automatically reported and calculated by maintaining persistent
72 // and process-local state variables.
73 virtual void ReportUpdateCheckMetrics(
74 SystemState* system_state,
75 metrics::CheckResult result,
76 metrics::CheckReaction reaction,
77 metrics::DownloadErrorCode download_error_code) = 0;
78
79 // Helper function to report metrics after the completion of each
80 // update attempt. The following metrics are reported:
81 //
82 // |kMetricAttemptNumber|
83 // |kMetricAttemptPayloadType|
84 // |kMetricAttemptPayloadSizeMiB|
Tianjie Xu1b661142017-09-28 14:03:42 -070085 // |kMetricAttemptDurationMinutes|
86 // |kMetricAttemptDurationUptimeMinutes|
Tianjie Xu282aa1f2017-09-05 13:42:45 -070087 // |kMetricAttemptTimeSinceLastAttemptMinutes|
88 // |kMetricAttemptTimeSinceLastAttemptUptimeMinutes|
89 // |kMetricAttemptPayloadBytesDownloadedMiB|
90 // |kMetricAttemptPayloadDownloadSpeedKBps|
91 // |kMetricAttemptDownloadSource|
92 // |kMetricAttemptResult|
93 // |kMetricAttemptInternalErrorCode|
94 // |kMetricAttemptDownloadErrorCode|
95 //
96 // The |kMetricAttemptInternalErrorCode| metric will only be reported
97 // if |internal_error_code| is not |kErrorSuccess|.
98 //
99 // The |kMetricAttemptDownloadErrorCode| metric will only be
100 // reported if |payload_download_error_code| is not |kUnset|.
101 //
102 // The values for the |kMetricAttemptTimeSinceLastAttemptMinutes| and
103 // |kMetricAttemptTimeSinceLastAttemptUptimeMinutes| metrics are
104 // automatically calculated and reported by maintaining persistent and
105 // process-local state variables.
106 virtual void ReportUpdateAttemptMetrics(
107 SystemState* system_state,
108 int attempt_number,
109 PayloadType payload_type,
110 base::TimeDelta duration,
111 base::TimeDelta duration_uptime,
112 int64_t payload_size,
113 int64_t payload_bytes_downloaded,
114 int64_t payload_download_speed_bps,
115 DownloadSource download_source,
116 metrics::AttemptResult attempt_result,
117 ErrorCode internal_error_code,
118 metrics::DownloadErrorCode payload_download_error_code,
119 metrics::ConnectionType connection_type) = 0;
120
121 // Reports the |kAbnormalTermination| for the |kMetricAttemptResult|
122 // metric. No other metrics in the UpdateEngine.Attempt.* namespace
123 // will be reported.
124 virtual void ReportAbnormallyTerminatedUpdateAttemptMetrics() = 0;
125
126 // Helper function to report the after the completion of a successful
127 // update attempt. The following metrics are reported:
128 //
129 // |kMetricSuccessfulUpdateAttemptCount|
130 // |kMetricSuccessfulUpdateUpdatesAbandonedCount|
131 // |kMetricSuccessfulUpdatePayloadType|
132 // |kMetricSuccessfulUpdatePayloadSizeMiB|
133 // |kMetricSuccessfulUpdateBytesDownloadedMiBHttpsServer|
134 // |kMetricSuccessfulUpdateBytesDownloadedMiBHttpServer|
135 // |kMetricSuccessfulUpdateBytesDownloadedMiBHttpPeer|
136 // |kMetricSuccessfulUpdateBytesDownloadedMiB|
137 // |kMetricSuccessfulUpdateDownloadSourcesUsed|
138 // |kMetricSuccessfulUpdateDownloadOverheadPercentage|
139 // |kMetricSuccessfulUpdateTotalDurationMinutes|
140 // |kMetricSuccessfulUpdateRebootCount|
141 // |kMetricSuccessfulUpdateUrlSwitchCount|
142 //
143 // The values for the |kMetricSuccessfulUpdateDownloadSourcesUsed| are
144 // |kMetricSuccessfulUpdateBytesDownloadedMiB| metrics automatically
145 // calculated from examining the |num_bytes_downloaded| array.
146 virtual void ReportSuccessfulUpdateMetrics(
147 int attempt_count,
148 int updates_abandoned_count,
149 PayloadType payload_type,
150 int64_t payload_size,
151 int64_t num_bytes_downloaded[kNumDownloadSources],
152 int download_overhead_percentage,
153 base::TimeDelta total_duration,
154 int reboot_count,
155 int url_switch_count) = 0;
156
157 // Helper function to report the after the completion of a SSL certificate
158 // check. One of the following metrics is reported:
159 //
160 // |kMetricCertificateCheckUpdateCheck|
161 // |kMetricCertificateCheckDownload|
162 virtual void ReportCertificateCheckMetrics(ServerToCheck server_to_check,
163 CertificateCheckResult result) = 0;
164
165 // Helper function to report the number failed update attempts. The following
166 // metrics are reported:
167 //
168 // |kMetricFailedUpdateCount|
169 virtual void ReportFailedUpdateCount(int target_attempt) = 0;
170
171 // Helper function to report the time interval in minutes between a
172 // successful update and the reboot into the updated system. The following
173 // metrics are reported:
174 //
175 // |kMetricTimeToRebootMinutes|
176 virtual void ReportTimeToReboot(int time_to_reboot_minutes) = 0;
177
178 // Helper function to report the source of installation data. The following
179 // metrics are reported:
180 //
181 // |kMetricInstallDateProvisioningSource|
182 virtual void ReportInstallDateProvisioningSource(int source, int max) = 0;
183};
184
185} // namespace chromeos_update_engine
186
187#endif // UPDATE_ENGINE_METRICS_REPORTER_INTERFACE_H_