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_COMMON_METRICS_CONSTANTS_H_ 18 #define UPDATE_ENGINE_COMMON_METRICS_CONSTANTS_H_ 19 20 #include <chrono> 21 namespace chromeos_update_engine { 22 23 namespace metrics { 24 // The possible outcomes when checking for updates. 25 // 26 // This is used in the UpdateEngine.Check.Result histogram. 27 enum class CheckResult { 28 kUpdateAvailable, // Response indicates an update is available. 29 kNoUpdateAvailable, // Response indicates no updates are available. 30 kDownloadError, // Error downloading response from Omaha. 31 kParsingError, // Error parsing response. 32 kRebootPending, // No update check was performed a reboot is pending. 33 34 kNumConstants, 35 kUnset = -1 36 }; 37 38 // Possible ways a device can react to a new update being available. 39 // 40 // This is used in the UpdateEngine.Check.Reaction histogram. 41 enum class CheckReaction { 42 kUpdating, // Device proceeds to download and apply update. 43 kIgnored, // Device-policy dictates ignoring the update. 44 kDeferring, // Device-policy dictates waiting. 45 kBackingOff, // Previous errors dictates waiting. 46 47 kNumConstants, 48 kUnset = -1 49 }; 50 51 // The possible ways that downloading from a HTTP or HTTPS server can fail. 52 // 53 // This is used in the UpdateEngine.Check.DownloadErrorCode and 54 // UpdateEngine.Attempt.DownloadErrorCode histograms. 55 enum class DownloadErrorCode { 56 // Errors that can happen in the field. See http://crbug.com/355745 57 // for how we plan to add more detail in the future. 58 kDownloadError = 0, // Error downloading data from server. 59 60 // IMPORTANT: When adding a new error code, add at the bottom of the 61 // above block and before the kInputMalformed field. This 62 // is to ensure that error codes are not reordered. 63 64 // This error is reported when libcurl returns CURLE_COULDNT_RESOLVE_HOST and 65 // calling res_init() can recover. 66 kUnresolvedHostRecovered = 97, 67 // This error is reported when libcurl returns CURLE_COULDNT_RESOLVE_HOST. 68 kUnresolvedHostError = 98, 69 // This error is reported when libcurl has an internal error that 70 // update_engine can't recover from. 71 kInternalLibCurlError = 99, 72 73 // This error code is used to convey that malformed input was given 74 // to the utils::GetDownloadErrorCode() function. This should never 75 // happen but if it does it's because of an internal update_engine 76 // error and we're interested in knowing this. 77 kInputMalformed = 100, 78 79 // Bucket for capturing HTTP status codes not in the 200-599 80 // range. This should never happen in practice but if it does we 81 // want to know. 82 kHttpStatusOther = 101, 83 84 // Above 200 and below 600, the value is the HTTP status code. 85 kHttpStatus200 = 200, 86 87 kNumConstants = 600, 88 89 kUnset = -1 90 }; 91 92 // Possible ways an update attempt can end. 93 // 94 // This is used in the UpdateEngine.Attempt.Result histogram. 95 enum class AttemptResult { 96 kUpdateSucceeded, // The update succeeded. 97 kInternalError, // An internal error occurred. 98 kPayloadDownloadError, // Failure while downloading payload. 99 kMetadataMalformed, // Metadata was malformed. 100 kOperationMalformed, // An operation was malformed. 101 kOperationExecutionError, // An operation failed to execute. 102 kMetadataVerificationFailed, // Metadata verification failed. 103 kPayloadVerificationFailed, // Payload verification failed. 104 kVerificationFailed, // Root or Kernel partition verification failed. 105 kPostInstallFailed, // The postinstall step failed. 106 kAbnormalTermination, // The attempt ended abnormally. 107 kUpdateCanceled, // Update canceled by the user. 108 kUpdateSucceededNotActive, // Update succeeded but the new slot is not 109 // active. 110 kUpdateSkipped, // Current update skipped. 111 kNumConstants, 112 113 kUnset = -1 114 }; 115 116 // Possible ways the device is connected to the Internet. 117 // 118 // This is used in the UpdateEngine.Attempt.ConnectionType histogram. 119 enum class ConnectionType { 120 kUnknown = 0, // Unknown. 121 kEthernet = 1, // Ethernet. 122 kWifi = 2, // Wireless. 123 kCellular = 5, // Cellular. 124 kTetheredEthernet = 6, // Tethered (Ethernet). 125 kTetheredWifi = 7, // Tethered (Wifi). 126 kDisconnected = 8, // Disconnected. 127 // deprecated: kWimax = 3, 128 // deprecated: kBluetooth = 4, 129 130 kNumConstants, 131 kUnset = -1 132 }; 133 134 // Possible ways a rollback can end. 135 // 136 // This is used in the UpdateEngine.Rollback histogram. 137 enum class RollbackResult { 138 kFailed, 139 kSuccess, 140 141 kNumConstants 142 }; 143 144 constexpr auto kMetricFlushInterval = std::chrono::seconds(3); 145 146 } // namespace metrics 147 148 } // namespace chromeos_update_engine 149 150 #endif // UPDATE_ENGINE_COMMON_METRICS_CONSTANTS_H_ 151