Yao Chen | b356151 | 2017-11-21 18:07:17 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 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 | #pragma once |
| 17 | |
| 18 | #include "config/ConfigKey.h" |
Chenjie Yu | b038b70 | 2017-12-18 15:15:34 -0800 | [diff] [blame] | 19 | #include "statslog.h" |
Yao Chen | b356151 | 2017-11-21 18:07:17 -0800 | [diff] [blame] | 20 | |
Yao Chen | 69f1baf | 2017-11-27 17:25:36 -0800 | [diff] [blame] | 21 | #include <gtest/gtest_prod.h> |
David Chen | d9269e2 | 2017-12-05 13:43:51 -0800 | [diff] [blame] | 22 | #include <log/log_time.h> |
Yao Chen | f6723df | 2018-01-08 15:11:58 -0800 | [diff] [blame] | 23 | #include <list> |
Yao Chen | b356151 | 2017-11-21 18:07:17 -0800 | [diff] [blame] | 24 | #include <mutex> |
| 25 | #include <string> |
| 26 | #include <vector> |
| 27 | |
| 28 | namespace android { |
| 29 | namespace os { |
| 30 | namespace statsd { |
| 31 | |
Yao Chen | 20e9e62 | 2018-02-28 11:18:51 -0800 | [diff] [blame] | 32 | struct ConfigStats { |
| 33 | int32_t uid; |
| 34 | int64_t id; |
| 35 | int32_t creation_time_sec; |
| 36 | int32_t deletion_time_sec = 0; |
Yangster-mac | b142cc8 | 2018-03-30 15:22:08 -0700 | [diff] [blame] | 37 | int32_t reset_time_sec = 0; |
Yao Chen | 20e9e62 | 2018-02-28 11:18:51 -0800 | [diff] [blame] | 38 | int32_t metric_count; |
| 39 | int32_t condition_count; |
| 40 | int32_t matcher_count; |
| 41 | int32_t alert_count; |
| 42 | bool is_valid; |
| 43 | |
| 44 | std::list<int32_t> broadcast_sent_time_sec; |
| 45 | std::list<int32_t> data_drop_time_sec; |
| 46 | std::list<int32_t> dump_report_time_sec; |
| 47 | |
| 48 | // Stores how many times a matcher have been matched. The map size is capped by kMaxConfigCount. |
| 49 | std::map<const int64_t, int> matcher_stats; |
| 50 | |
| 51 | // Stores the number of output tuple of condition trackers when it's bigger than |
| 52 | // kDimensionKeySizeSoftLimit. When you see the number is kDimensionKeySizeHardLimit +1, |
| 53 | // it means some data has been dropped. The map size is capped by kMaxConfigCount. |
| 54 | std::map<const int64_t, int> condition_stats; |
| 55 | |
| 56 | // Stores the number of output tuple of metric producers when it's bigger than |
| 57 | // kDimensionKeySizeSoftLimit. When you see the number is kDimensionKeySizeHardLimit +1, |
| 58 | // it means some data has been dropped. The map size is capped by kMaxConfigCount. |
| 59 | std::map<const int64_t, int> metric_stats; |
| 60 | |
Yangster-mac | 306ccc2 | 2018-03-24 15:03:40 -0700 | [diff] [blame] | 61 | // Stores the max number of output tuple of dimensions in condition across dimensions in what |
| 62 | // when it's bigger than kDimensionKeySizeSoftLimit. When you see the number is |
| 63 | // kDimensionKeySizeHardLimit +1, it means some data has been dropped. The map size is capped by |
| 64 | // kMaxConfigCount. |
| 65 | std::map<const int64_t, int> metric_dimension_in_condition_stats; |
| 66 | |
Yao Chen | 20e9e62 | 2018-02-28 11:18:51 -0800 | [diff] [blame] | 67 | // Stores the number of times an anomaly detection alert has been declared. |
| 68 | // The map size is capped by kMaxConfigCount. |
| 69 | std::map<const int64_t, int> alert_stats; |
David Chen | faa1af5 | 2018-03-30 15:14:04 -0700 | [diff] [blame] | 70 | |
| 71 | // Stores the config ID for each sub-config used. |
| 72 | std::list<std::pair<const int64_t, const int32_t>> annotations; |
Yao Chen | 20e9e62 | 2018-02-28 11:18:51 -0800 | [diff] [blame] | 73 | }; |
| 74 | |
| 75 | struct UidMapStats { |
| 76 | int32_t snapshots; |
| 77 | int32_t changes; |
| 78 | int32_t bytes_used; |
| 79 | int32_t dropped_snapshots; |
| 80 | int32_t dropped_changes; |
| 81 | }; |
| 82 | |
Yao Chen | b356151 | 2017-11-21 18:07:17 -0800 | [diff] [blame] | 83 | // Keeps track of stats of statsd. |
Yao Chen | 20e9e62 | 2018-02-28 11:18:51 -0800 | [diff] [blame] | 84 | // Single instance shared across the process. All public methods are thread safe. |
Yao Chen | b356151 | 2017-11-21 18:07:17 -0800 | [diff] [blame] | 85 | class StatsdStats { |
| 86 | public: |
| 87 | static StatsdStats& getInstance(); |
| 88 | ~StatsdStats(){}; |
| 89 | |
| 90 | // TODO: set different limit if the device is low ram. |
Yao Chen | 52b478b | 2018-03-27 10:59:45 -0700 | [diff] [blame] | 91 | const static int kDimensionKeySizeSoftLimit = 500; |
| 92 | const static int kDimensionKeySizeHardLimit = 800; |
Yao Chen | b356151 | 2017-11-21 18:07:17 -0800 | [diff] [blame] | 93 | |
Chenjie Yu | c587505 | 2018-03-09 10:13:11 -0800 | [diff] [blame] | 94 | // Per atom dimension key size limit |
| 95 | static const std::map<int, std::pair<size_t, size_t>> kAtomDimensionKeySizeLimitMap; |
| 96 | |
Yao Chen | 52b478b | 2018-03-27 10:59:45 -0700 | [diff] [blame] | 97 | const static int kMaxConfigCountPerUid = 10; |
Bookatz | 1476ef2 | 2018-02-13 12:26:01 -0800 | [diff] [blame] | 98 | const static int kMaxAlertCountPerConfig = 100; |
Yao Chen | 52b478b | 2018-03-27 10:59:45 -0700 | [diff] [blame] | 99 | const static int kMaxConditionCountPerConfig = 300; |
| 100 | const static int kMaxMetricCountPerConfig = 1000; |
| 101 | const static int kMaxMatcherCountPerConfig = 800; |
Yao Chen | b356151 | 2017-11-21 18:07:17 -0800 | [diff] [blame] | 102 | |
Yao Chen | f6723df | 2018-01-08 15:11:58 -0800 | [diff] [blame] | 103 | // The max number of old config stats we keep. |
| 104 | const static int kMaxIceBoxSize = 20; |
| 105 | |
Yao Chen | 884c8c1 | 2018-01-26 10:36:25 -0800 | [diff] [blame] | 106 | const static int kMaxLoggerErrors = 10; |
| 107 | |
Yangster-mac | b8382a1 | 2018-04-04 10:39:12 -0700 | [diff] [blame^] | 108 | const static int kMaxSkippedLogEvents = 200; |
| 109 | |
Yao Chen | 0fac5b1 | 2017-11-28 16:07:02 -0800 | [diff] [blame] | 110 | const static int kMaxTimestampCount = 20; |
| 111 | |
Yao Chen | d10f7b1 | 2017-12-18 12:53:50 -0800 | [diff] [blame] | 112 | const static int kMaxLogSourceCount = 50; |
| 113 | |
David Chen | 4c6d97a | 2018-03-22 16:31:40 -0700 | [diff] [blame] | 114 | // Max memory allowed for storing metrics per configuration. If this limit is exceeded, statsd |
| 115 | // drops the metrics data in memory. |
| 116 | static const size_t kMaxMetricsBytesPerConfig = 256 * 1024; |
| 117 | |
| 118 | // Soft memory limit per configuration. Once this limit is exceeded, we begin notifying the |
| 119 | // data subscriber that it's time to call getData. |
| 120 | static const size_t kBytesPerConfigTriggerGetData = 128 * 1024; |
David Chen | d9269e2 | 2017-12-05 13:43:51 -0800 | [diff] [blame] | 121 | |
David Chen | c136f45 | 2017-11-27 11:52:26 -0800 | [diff] [blame] | 122 | // Cap the UID map's memory usage to this. This should be fairly high since the UID information |
| 123 | // is critical for understanding the metrics. |
| 124 | const static size_t kMaxBytesUsedUidMap = 50 * 1024; |
| 125 | |
David Chen | d9269e2 | 2017-12-05 13:43:51 -0800 | [diff] [blame] | 126 | /* Minimum period between two broadcasts in nanoseconds. */ |
Yangster-mac | b142cc8 | 2018-03-30 15:22:08 -0700 | [diff] [blame] | 127 | static const int64_t kMinBroadcastPeriodNs = 60 * NS_PER_SEC; |
David Chen | d9269e2 | 2017-12-05 13:43:51 -0800 | [diff] [blame] | 128 | |
| 129 | /* Min period between two checks of byte size per config key in nanoseconds. */ |
Yangster-mac | b142cc8 | 2018-03-30 15:22:08 -0700 | [diff] [blame] | 130 | static const int64_t kMinByteSizeCheckPeriodNs = 10 * NS_PER_SEC; |
David Chen | d9269e2 | 2017-12-05 13:43:51 -0800 | [diff] [blame] | 131 | |
yro | 98a2850 | 2018-01-18 17:00:14 -0800 | [diff] [blame] | 132 | // Maximum age (30 days) that files on disk can exist in seconds. |
| 133 | static const int kMaxAgeSecond = 60 * 60 * 24 * 30; |
| 134 | |
| 135 | // Maximum number of files (1000) that can be in stats directory on disk. |
| 136 | static const int kMaxFileNumber = 1000; |
| 137 | |
| 138 | // Maximum size of all files that can be written to stats directory on disk. |
| 139 | static const int kMaxFileSize = 50 * 1024 * 1024; |
| 140 | |
Chenjie Yu | fa22d65 | 2018-02-05 14:37:48 -0800 | [diff] [blame] | 141 | // How long to try to clear puller cache from last time |
| 142 | static const long kPullerCacheClearIntervalSec = 1; |
| 143 | |
Yao Chen | b356151 | 2017-11-21 18:07:17 -0800 | [diff] [blame] | 144 | /** |
| 145 | * Report a new config has been received and report the static stats about the config. |
| 146 | * |
| 147 | * The static stats include: the count of metrics, conditions, matchers, and alerts. |
| 148 | * If the config is not valid, this config stats will be put into icebox immediately. |
| 149 | */ |
| 150 | void noteConfigReceived(const ConfigKey& key, int metricsCount, int conditionsCount, |
David Chen | faa1af5 | 2018-03-30 15:14:04 -0700 | [diff] [blame] | 151 | int matchersCount, int alertCount, |
| 152 | const std::list<std::pair<const int64_t, const int32_t>>& annotations, |
| 153 | bool isValid); |
Yao Chen | b356151 | 2017-11-21 18:07:17 -0800 | [diff] [blame] | 154 | /** |
| 155 | * Report a config has been removed. |
| 156 | */ |
| 157 | void noteConfigRemoved(const ConfigKey& key); |
Yangster-mac | b142cc8 | 2018-03-30 15:22:08 -0700 | [diff] [blame] | 158 | /** |
| 159 | * Report a config has been reset when ttl expires. |
| 160 | */ |
| 161 | void noteConfigReset(const ConfigKey& key); |
Yao Chen | b356151 | 2017-11-21 18:07:17 -0800 | [diff] [blame] | 162 | |
| 163 | /** |
| 164 | * Report a broadcast has been sent to a config owner to collect the data. |
| 165 | */ |
| 166 | void noteBroadcastSent(const ConfigKey& key); |
| 167 | |
| 168 | /** |
| 169 | * Report a config's metrics data has been dropped. |
| 170 | */ |
Yao Chen | 69f1baf | 2017-11-27 17:25:36 -0800 | [diff] [blame] | 171 | void noteDataDropped(const ConfigKey& key); |
| 172 | |
| 173 | /** |
| 174 | * Report metrics data report has been sent. |
| 175 | * |
| 176 | * The report may be requested via StatsManager API, or through adb cmd. |
| 177 | */ |
| 178 | void noteMetricsReportSent(const ConfigKey& key); |
Yao Chen | b356151 | 2017-11-21 18:07:17 -0800 | [diff] [blame] | 179 | |
| 180 | /** |
| 181 | * Report the size of output tuple of a condition. |
| 182 | * |
| 183 | * Note: only report when the condition has an output dimension, and the tuple |
| 184 | * count > kDimensionKeySizeSoftLimit. |
| 185 | * |
| 186 | * [key]: The config key that this condition belongs to. |
Yangster-mac | 94e197c | 2018-01-02 16:03:03 -0800 | [diff] [blame] | 187 | * [id]: The id of the condition. |
Yao Chen | b356151 | 2017-11-21 18:07:17 -0800 | [diff] [blame] | 188 | * [size]: The output tuple size. |
| 189 | */ |
Yangster-mac | 94e197c | 2018-01-02 16:03:03 -0800 | [diff] [blame] | 190 | void noteConditionDimensionSize(const ConfigKey& key, const int64_t& id, int size); |
Yao Chen | b356151 | 2017-11-21 18:07:17 -0800 | [diff] [blame] | 191 | |
| 192 | /** |
| 193 | * Report the size of output tuple of a metric. |
| 194 | * |
| 195 | * Note: only report when the metric has an output dimension, and the tuple |
| 196 | * count > kDimensionKeySizeSoftLimit. |
| 197 | * |
| 198 | * [key]: The config key that this metric belongs to. |
Yangster-mac | 94e197c | 2018-01-02 16:03:03 -0800 | [diff] [blame] | 199 | * [id]: The id of the metric. |
Yao Chen | b356151 | 2017-11-21 18:07:17 -0800 | [diff] [blame] | 200 | * [size]: The output tuple size. |
| 201 | */ |
Yangster-mac | 94e197c | 2018-01-02 16:03:03 -0800 | [diff] [blame] | 202 | void noteMetricDimensionSize(const ConfigKey& key, const int64_t& id, int size); |
Yao Chen | b356151 | 2017-11-21 18:07:17 -0800 | [diff] [blame] | 203 | |
Yangster-mac | 306ccc2 | 2018-03-24 15:03:40 -0700 | [diff] [blame] | 204 | |
| 205 | /** |
| 206 | * Report the max size of output tuple of dimension in condition across dimensions in what. |
| 207 | * |
| 208 | * Note: only report when the metric has an output dimension in condition, and the max tuple |
| 209 | * count > kDimensionKeySizeSoftLimit. |
| 210 | * |
| 211 | * [key]: The config key that this metric belongs to. |
| 212 | * [id]: The id of the metric. |
| 213 | * [size]: The output tuple size. |
| 214 | */ |
| 215 | void noteMetricDimensionInConditionSize(const ConfigKey& key, const int64_t& id, int size); |
| 216 | |
Yao Chen | b356151 | 2017-11-21 18:07:17 -0800 | [diff] [blame] | 217 | /** |
| 218 | * Report a matcher has been matched. |
| 219 | * |
| 220 | * [key]: The config key that this matcher belongs to. |
Yangster-mac | 94e197c | 2018-01-02 16:03:03 -0800 | [diff] [blame] | 221 | * [id]: The id of the matcher. |
Yao Chen | b356151 | 2017-11-21 18:07:17 -0800 | [diff] [blame] | 222 | */ |
Yangster-mac | 94e197c | 2018-01-02 16:03:03 -0800 | [diff] [blame] | 223 | void noteMatcherMatched(const ConfigKey& key, const int64_t& id); |
Yao Chen | b356151 | 2017-11-21 18:07:17 -0800 | [diff] [blame] | 224 | |
| 225 | /** |
Bookatz | 8f2f3d8 | 2017-12-07 13:53:21 -0800 | [diff] [blame] | 226 | * Report that an anomaly detection alert has been declared. |
| 227 | * |
| 228 | * [key]: The config key that this alert belongs to. |
Yangster-mac | 94e197c | 2018-01-02 16:03:03 -0800 | [diff] [blame] | 229 | * [id]: The id of the alert. |
Bookatz | 8f2f3d8 | 2017-12-07 13:53:21 -0800 | [diff] [blame] | 230 | */ |
Yangster-mac | 94e197c | 2018-01-02 16:03:03 -0800 | [diff] [blame] | 231 | void noteAnomalyDeclared(const ConfigKey& key, const int64_t& id); |
Bookatz | 8f2f3d8 | 2017-12-07 13:53:21 -0800 | [diff] [blame] | 232 | |
| 233 | /** |
Yao Chen | b356151 | 2017-11-21 18:07:17 -0800 | [diff] [blame] | 234 | * Report an atom event has been logged. |
| 235 | */ |
| 236 | void noteAtomLogged(int atomId, int32_t timeSec); |
| 237 | |
| 238 | /** |
Bookatz | 1d0136d | 2017-12-01 11:13:32 -0800 | [diff] [blame] | 239 | * Report that statsd modified the anomaly alarm registered with StatsCompanionService. |
| 240 | */ |
| 241 | void noteRegisteredAnomalyAlarmChanged(); |
| 242 | |
| 243 | /** |
Yangster-mac | 932ecec | 2018-02-01 10:23:52 -0800 | [diff] [blame] | 244 | * Report that statsd modified the periodic alarm registered with StatsCompanionService. |
| 245 | */ |
| 246 | void noteRegisteredPeriodicAlarmChanged(); |
| 247 | |
| 248 | /** |
David Chen | c136f45 | 2017-11-27 11:52:26 -0800 | [diff] [blame] | 249 | * Records the number of snapshot and delta entries that are being dropped from the uid map. |
| 250 | */ |
| 251 | void noteUidMapDropped(int snapshots, int deltas); |
| 252 | |
| 253 | /** |
| 254 | * Updates the number of snapshots currently stored in the uid map. |
| 255 | */ |
| 256 | void setUidMapSnapshots(int snapshots); |
| 257 | void setUidMapChanges(int changes); |
| 258 | void setCurrentUidMapMemory(int bytes); |
| 259 | |
Chenjie Yu | b038b70 | 2017-12-18 15:15:34 -0800 | [diff] [blame] | 260 | // Update minimum interval between pulls for an pulled atom |
| 261 | void updateMinPullIntervalSec(int pullAtomId, long intervalSec); |
| 262 | |
| 263 | // Notify pull request for an atom |
| 264 | void notePull(int pullAtomId); |
| 265 | |
| 266 | // Notify pull request for an atom served from cached data |
| 267 | void notePullFromCache(int pullAtomId); |
| 268 | |
David Chen | c136f45 | 2017-11-27 11:52:26 -0800 | [diff] [blame] | 269 | /** |
Yao Chen | 884c8c1 | 2018-01-26 10:36:25 -0800 | [diff] [blame] | 270 | * Records statsd met an error while reading from logd. |
| 271 | */ |
| 272 | void noteLoggerError(int error); |
| 273 | |
| 274 | /** |
Yangster-mac | b8382a1 | 2018-04-04 10:39:12 -0700 | [diff] [blame^] | 275 | * Records statsd skipped an event. |
| 276 | */ |
| 277 | void noteLogEventSkipped(int tag, int64_t timestamp); |
| 278 | |
| 279 | /** |
Yao Chen | b356151 | 2017-11-21 18:07:17 -0800 | [diff] [blame] | 280 | * Reset the historical stats. Including all stats in icebox, and the tracked stats about |
| 281 | * metrics, matchers, and atoms. The active configs will be kept and StatsdStats will continue |
| 282 | * to collect stats after reset() has been called. |
| 283 | */ |
| 284 | void reset(); |
| 285 | |
| 286 | /** |
| 287 | * Output the stats in protobuf binary format to [buffer]. |
| 288 | * |
| 289 | * [reset]: whether to clear the historical stats after the call. |
| 290 | */ |
Yao Chen | 69f1baf | 2017-11-27 17:25:36 -0800 | [diff] [blame] | 291 | void dumpStats(std::vector<uint8_t>* buffer, bool reset); |
Yao Chen | b356151 | 2017-11-21 18:07:17 -0800 | [diff] [blame] | 292 | |
Yao Chen | f5acabe | 2018-01-17 14:10:34 -0800 | [diff] [blame] | 293 | /** |
| 294 | * Output statsd stats in human readable format to [out] file. |
| 295 | */ |
| 296 | void dumpStats(FILE* out) const; |
| 297 | |
Chenjie Yu | b038b70 | 2017-12-18 15:15:34 -0800 | [diff] [blame] | 298 | typedef struct { |
| 299 | long totalPull; |
| 300 | long totalPullFromCache; |
| 301 | long minPullIntervalSec; |
| 302 | } PulledAtomStats; |
| 303 | |
Yao Chen | b356151 | 2017-11-21 18:07:17 -0800 | [diff] [blame] | 304 | private: |
| 305 | StatsdStats(); |
| 306 | |
| 307 | mutable std::mutex mLock; |
| 308 | |
Yao Chen | 69f1baf | 2017-11-27 17:25:36 -0800 | [diff] [blame] | 309 | int32_t mStartTimeSec; |
Yao Chen | b356151 | 2017-11-21 18:07:17 -0800 | [diff] [blame] | 310 | |
David Chen | c136f45 | 2017-11-27 11:52:26 -0800 | [diff] [blame] | 311 | // Track the number of dropped entries used by the uid map. |
Yao Chen | 20e9e62 | 2018-02-28 11:18:51 -0800 | [diff] [blame] | 312 | UidMapStats mUidMapStats; |
David Chen | c136f45 | 2017-11-27 11:52:26 -0800 | [diff] [blame] | 313 | |
Yao Chen | b356151 | 2017-11-21 18:07:17 -0800 | [diff] [blame] | 314 | // The stats about the configs that are still in use. |
Yao Chen | f6723df | 2018-01-08 15:11:58 -0800 | [diff] [blame] | 315 | // The map size is capped by kMaxConfigCount. |
Yao Chen | 20e9e62 | 2018-02-28 11:18:51 -0800 | [diff] [blame] | 316 | std::map<const ConfigKey, std::shared_ptr<ConfigStats>> mConfigStats; |
Yao Chen | b356151 | 2017-11-21 18:07:17 -0800 | [diff] [blame] | 317 | |
| 318 | // Stores the stats for the configs that are no longer in use. |
Yao Chen | f6723df | 2018-01-08 15:11:58 -0800 | [diff] [blame] | 319 | // The size of the vector is capped by kMaxIceBoxSize. |
Yao Chen | 20e9e62 | 2018-02-28 11:18:51 -0800 | [diff] [blame] | 320 | std::list<const std::shared_ptr<ConfigStats>> mIceBox; |
Yao Chen | b356151 | 2017-11-21 18:07:17 -0800 | [diff] [blame] | 321 | |
| 322 | // Stores the number of times a pushed atom is logged. |
| 323 | // The size of the vector is the largest pushed atom id in atoms.proto + 1. Atoms |
| 324 | // out of that range will be dropped (it's either pulled atoms or test atoms). |
| 325 | // This is a vector, not a map because it will be accessed A LOT -- for each stats log. |
| 326 | std::vector<int> mPushedAtomStats; |
| 327 | |
Yao Chen | f6723df | 2018-01-08 15:11:58 -0800 | [diff] [blame] | 328 | // Maps PullAtomId to its stats. The size is capped by the puller atom counts. |
Chenjie Yu | b038b70 | 2017-12-18 15:15:34 -0800 | [diff] [blame] | 329 | std::map<int, PulledAtomStats> mPulledAtomStats; |
| 330 | |
Yao Chen | 884c8c1 | 2018-01-26 10:36:25 -0800 | [diff] [blame] | 331 | // Logd errors. Size capped by kMaxLoggerErrors. |
| 332 | std::list<const std::pair<int, int>> mLoggerErrors; |
| 333 | |
Yangster-mac | b8382a1 | 2018-04-04 10:39:12 -0700 | [diff] [blame^] | 334 | // Skipped log events. |
| 335 | std::list<const std::pair<int, int64_t>> mSkippedLogEvents; |
| 336 | |
Bookatz | 1d0136d | 2017-12-01 11:13:32 -0800 | [diff] [blame] | 337 | // Stores the number of times statsd modified the anomaly alarm registered with |
| 338 | // StatsCompanionService. |
| 339 | int mAnomalyAlarmRegisteredStats = 0; |
| 340 | |
Yangster-mac | 932ecec | 2018-02-01 10:23:52 -0800 | [diff] [blame] | 341 | // Stores the number of times statsd registers the periodic alarm changes |
| 342 | int mPeriodicAlarmRegisteredStats = 0; |
| 343 | |
Yangster-mac | b142cc8 | 2018-03-30 15:22:08 -0700 | [diff] [blame] | 344 | void noteConfigResetInternalLocked(const ConfigKey& key); |
Yao Chen | b356151 | 2017-11-21 18:07:17 -0800 | [diff] [blame] | 345 | |
| 346 | void noteConfigRemovedInternalLocked(const ConfigKey& key); |
| 347 | |
| 348 | void resetInternalLocked(); |
| 349 | |
Yao Chen | 0fac5b1 | 2017-11-28 16:07:02 -0800 | [diff] [blame] | 350 | void noteDataDropped(const ConfigKey& key, int32_t timeSec); |
| 351 | |
| 352 | void noteMetricsReportSent(const ConfigKey& key, int32_t timeSec); |
| 353 | |
| 354 | void noteBroadcastSent(const ConfigKey& key, int32_t timeSec); |
| 355 | |
Yao Chen | 20e9e62 | 2018-02-28 11:18:51 -0800 | [diff] [blame] | 356 | void addToIceBoxLocked(std::shared_ptr<ConfigStats>& stats); |
Yao Chen | f6723df | 2018-01-08 15:11:58 -0800 | [diff] [blame] | 357 | |
Yao Chen | 69f1baf | 2017-11-27 17:25:36 -0800 | [diff] [blame] | 358 | FRIEND_TEST(StatsdStatsTest, TestValidConfigAdd); |
| 359 | FRIEND_TEST(StatsdStatsTest, TestInvalidConfigAdd); |
| 360 | FRIEND_TEST(StatsdStatsTest, TestConfigRemove); |
| 361 | FRIEND_TEST(StatsdStatsTest, TestSubStats); |
| 362 | FRIEND_TEST(StatsdStatsTest, TestAtomLog); |
Yao Chen | 0fac5b1 | 2017-11-28 16:07:02 -0800 | [diff] [blame] | 363 | FRIEND_TEST(StatsdStatsTest, TestTimestampThreshold); |
Bookatz | 1d0136d | 2017-12-01 11:13:32 -0800 | [diff] [blame] | 364 | FRIEND_TEST(StatsdStatsTest, TestAnomalyMonitor); |
Yao Chen | b356151 | 2017-11-21 18:07:17 -0800 | [diff] [blame] | 365 | }; |
| 366 | |
| 367 | } // namespace statsd |
| 368 | } // namespace os |
Stefan Lafon | c6f2fa2 | 2018-01-04 22:03:29 -0800 | [diff] [blame] | 369 | } // namespace android |