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