blob: bc9d387f65f98bfb06bf60f2094ba90ed775bcfb [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|
Tianjie Xu282aa1f2017-09-05 13:42:45 -070089 // |kMetricAttemptResult|
90 // |kMetricAttemptInternalErrorCode|
Tianjie Xu282aa1f2017-09-05 13:42:45 -070091 //
92 // The |kMetricAttemptInternalErrorCode| metric will only be reported
93 // if |internal_error_code| is not |kErrorSuccess|.
94 //
95 // The |kMetricAttemptDownloadErrorCode| metric will only be
96 // reported if |payload_download_error_code| is not |kUnset|.
97 //
98 // The values for the |kMetricAttemptTimeSinceLastAttemptMinutes| and
99 // |kMetricAttemptTimeSinceLastAttemptUptimeMinutes| metrics are
100 // automatically calculated and reported by maintaining persistent and
101 // process-local state variables.
Tianjie Xu1f93d092017-10-09 12:13:29 -0700102 virtual void ReportUpdateAttemptMetrics(SystemState* system_state,
103 int attempt_number,
104 PayloadType payload_type,
105 base::TimeDelta duration,
106 base::TimeDelta duration_uptime,
107 int64_t payload_size,
108 metrics::AttemptResult attempt_result,
109 ErrorCode internal_error_code) = 0;
110
111 // Helper function to report download metrics after the completion of each
112 // update attempt. The following metrics are reported:
113 //
114 // |kMetricAttemptPayloadBytesDownloadedMiB|
115 // |kMetricAttemptPayloadDownloadSpeedKBps|
116 // |kMetricAttemptDownloadSource|
117 // |kMetricAttemptDownloadErrorCode|
118 // |kMetricAttemptConnectionType|
119 virtual void ReportUpdateAttemptDownloadMetrics(
Tianjie Xu282aa1f2017-09-05 13:42:45 -0700120 int64_t payload_bytes_downloaded,
121 int64_t payload_download_speed_bps,
122 DownloadSource download_source,
Tianjie Xu282aa1f2017-09-05 13:42:45 -0700123 metrics::DownloadErrorCode payload_download_error_code,
124 metrics::ConnectionType connection_type) = 0;
125
126 // Reports the |kAbnormalTermination| for the |kMetricAttemptResult|
127 // metric. No other metrics in the UpdateEngine.Attempt.* namespace
128 // will be reported.
129 virtual void ReportAbnormallyTerminatedUpdateAttemptMetrics() = 0;
130
131 // Helper function to report the after the completion of a successful
132 // update attempt. The following metrics are reported:
133 //
134 // |kMetricSuccessfulUpdateAttemptCount|
135 // |kMetricSuccessfulUpdateUpdatesAbandonedCount|
136 // |kMetricSuccessfulUpdatePayloadType|
137 // |kMetricSuccessfulUpdatePayloadSizeMiB|
138 // |kMetricSuccessfulUpdateBytesDownloadedMiBHttpsServer|
139 // |kMetricSuccessfulUpdateBytesDownloadedMiBHttpServer|
140 // |kMetricSuccessfulUpdateBytesDownloadedMiBHttpPeer|
141 // |kMetricSuccessfulUpdateBytesDownloadedMiB|
142 // |kMetricSuccessfulUpdateDownloadSourcesUsed|
143 // |kMetricSuccessfulUpdateDownloadOverheadPercentage|
144 // |kMetricSuccessfulUpdateTotalDurationMinutes|
145 // |kMetricSuccessfulUpdateRebootCount|
146 // |kMetricSuccessfulUpdateUrlSwitchCount|
147 //
148 // The values for the |kMetricSuccessfulUpdateDownloadSourcesUsed| are
149 // |kMetricSuccessfulUpdateBytesDownloadedMiB| metrics automatically
150 // calculated from examining the |num_bytes_downloaded| array.
151 virtual void ReportSuccessfulUpdateMetrics(
152 int attempt_count,
153 int updates_abandoned_count,
154 PayloadType payload_type,
155 int64_t payload_size,
156 int64_t num_bytes_downloaded[kNumDownloadSources],
157 int download_overhead_percentage,
158 base::TimeDelta total_duration,
159 int reboot_count,
160 int url_switch_count) = 0;
161
162 // Helper function to report the after the completion of a SSL certificate
163 // check. One of the following metrics is reported:
164 //
165 // |kMetricCertificateCheckUpdateCheck|
166 // |kMetricCertificateCheckDownload|
167 virtual void ReportCertificateCheckMetrics(ServerToCheck server_to_check,
168 CertificateCheckResult result) = 0;
169
170 // Helper function to report the number failed update attempts. The following
171 // metrics are reported:
172 //
173 // |kMetricFailedUpdateCount|
174 virtual void ReportFailedUpdateCount(int target_attempt) = 0;
175
176 // Helper function to report the time interval in minutes between a
177 // successful update and the reboot into the updated system. The following
178 // metrics are reported:
179 //
180 // |kMetricTimeToRebootMinutes|
181 virtual void ReportTimeToReboot(int time_to_reboot_minutes) = 0;
182
183 // Helper function to report the source of installation data. The following
184 // metrics are reported:
185 //
186 // |kMetricInstallDateProvisioningSource|
187 virtual void ReportInstallDateProvisioningSource(int source, int max) = 0;
188};
189
190} // namespace chromeos_update_engine
191
192#endif // UPDATE_ENGINE_METRICS_REPORTER_INTERFACE_H_