Yao Chen | 44cf27c | 2017-09-14 22:32:50 -0700 | [diff] [blame] | 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 | */ |
Yao Chen | 44cf27c | 2017-09-14 22:32:50 -0700 | [diff] [blame] | 16 | #define DEBUG true // STOPSHIP if true |
Joe Onorato | 9fc9edf | 2017-10-15 20:08:52 -0700 | [diff] [blame] | 17 | #include "Log.h" |
Yao Chen | 44cf27c | 2017-09-14 22:32:50 -0700 | [diff] [blame] | 18 | #include "MetricsManager.h" |
Yao Chen | d10f7b1 | 2017-12-18 12:53:50 -0800 | [diff] [blame] | 19 | #include "statslog.h" |
Yao Chen | 93fe3a3 | 2017-11-02 13:52:59 -0700 | [diff] [blame] | 20 | |
Yao Chen | 44cf27c | 2017-09-14 22:32:50 -0700 | [diff] [blame] | 21 | #include "CountMetricProducer.h" |
Yao Chen | 93fe3a3 | 2017-11-02 13:52:59 -0700 | [diff] [blame] | 22 | #include "condition/CombinationConditionTracker.h" |
| 23 | #include "condition/SimpleConditionTracker.h" |
Yao Chen | b356151 | 2017-11-21 18:07:17 -0800 | [diff] [blame] | 24 | #include "guardrail/StatsdStats.h" |
Yao Chen | 93fe3a3 | 2017-11-02 13:52:59 -0700 | [diff] [blame] | 25 | #include "matchers/CombinationLogMatchingTracker.h" |
| 26 | #include "matchers/SimpleLogMatchingTracker.h" |
Yao Chen | caf339d | 2017-10-06 16:01:10 -0700 | [diff] [blame] | 27 | #include "metrics_manager_util.h" |
| 28 | #include "stats_util.h" |
Yao Chen | 44cf27c | 2017-09-14 22:32:50 -0700 | [diff] [blame] | 29 | |
Yao Chen | 93fe3a3 | 2017-11-02 13:52:59 -0700 | [diff] [blame] | 30 | #include <log/logprint.h> |
Yao Chen | 288c600 | 2017-12-12 13:43:18 -0800 | [diff] [blame] | 31 | |
| 32 | using android::util::FIELD_COUNT_REPEATED; |
| 33 | using android::util::FIELD_TYPE_MESSAGE; |
| 34 | using android::util::ProtoOutputStream; |
| 35 | |
Yao Chen | 44cf27c | 2017-09-14 22:32:50 -0700 | [diff] [blame] | 36 | using std::make_unique; |
| 37 | using std::set; |
| 38 | using std::string; |
Yao Chen | 44cf27c | 2017-09-14 22:32:50 -0700 | [diff] [blame] | 39 | using std::unordered_map; |
| 40 | using std::vector; |
| 41 | |
| 42 | namespace android { |
| 43 | namespace os { |
| 44 | namespace statsd { |
| 45 | |
Yao Chen | 288c600 | 2017-12-12 13:43:18 -0800 | [diff] [blame] | 46 | const int FIELD_ID_METRICS = 1; |
| 47 | |
Yao Chen | d10f7b1 | 2017-12-18 12:53:50 -0800 | [diff] [blame] | 48 | MetricsManager::MetricsManager(const ConfigKey& key, const StatsdConfig& config, |
| 49 | const long timeBaseSec, sp<UidMap> uidMap) |
| 50 | : mConfigKey(key), mUidMap(uidMap) { |
Yao Chen | b356151 | 2017-11-21 18:07:17 -0800 | [diff] [blame] | 51 | mConfigValid = |
Yangster-mac | 2087716 | 2017-12-22 17:19:39 -0800 | [diff] [blame] | 52 | initStatsdConfig(key, config, *uidMap, timeBaseSec, mTagIds, mAllAtomMatchers, mAllConditionTrackers, |
Yao Chen | b356151 | 2017-11-21 18:07:17 -0800 | [diff] [blame] | 53 | mAllMetricProducers, mAllAnomalyTrackers, mConditionToMetricMap, |
Yangster-mac | 94e197c | 2018-01-02 16:03:03 -0800 | [diff] [blame] | 54 | mTrackerToMetricMap, mTrackerToConditionMap, mNoReportMetricIds); |
Yao Chen | b356151 | 2017-11-21 18:07:17 -0800 | [diff] [blame] | 55 | |
Yao Chen | 147ce60 | 2017-12-22 14:35:34 -0800 | [diff] [blame] | 56 | if (config.allowed_log_source_size() == 0) { |
Yao Chen | d10f7b1 | 2017-12-18 12:53:50 -0800 | [diff] [blame] | 57 | // TODO(b/70794411): uncomment the following line and remove the hard coded log source |
| 58 | // after all configs have the log source added. |
| 59 | // mConfigValid = false; |
| 60 | // ALOGE("Log source white list is empty! This config won't get any data."); |
| 61 | |
| 62 | mAllowedUid.push_back(1000); |
| 63 | mAllowedUid.push_back(0); |
| 64 | mAllowedLogSources.insert(mAllowedUid.begin(), mAllowedUid.end()); |
| 65 | } else { |
Yao Chen | 147ce60 | 2017-12-22 14:35:34 -0800 | [diff] [blame] | 66 | for (const auto& source : config.allowed_log_source()) { |
| 67 | auto it = UidMap::sAidToUidMapping.find(source); |
| 68 | if (it != UidMap::sAidToUidMapping.end()) { |
| 69 | mAllowedUid.push_back(it->second); |
| 70 | } else { |
| 71 | mAllowedPkg.push_back(source); |
| 72 | } |
| 73 | } |
Yao Chen | d10f7b1 | 2017-12-18 12:53:50 -0800 | [diff] [blame] | 74 | |
| 75 | if (mAllowedUid.size() + mAllowedPkg.size() > StatsdStats::kMaxLogSourceCount) { |
| 76 | ALOGE("Too many log sources. This is likely to be an error in the config."); |
| 77 | mConfigValid = false; |
| 78 | } else { |
| 79 | initLogSourceWhiteList(); |
| 80 | } |
| 81 | } |
| 82 | |
Yao Chen | b356151 | 2017-11-21 18:07:17 -0800 | [diff] [blame] | 83 | // Guardrail. Reject the config if it's too big. |
| 84 | if (mAllMetricProducers.size() > StatsdStats::kMaxMetricCountPerConfig || |
| 85 | mAllConditionTrackers.size() > StatsdStats::kMaxConditionCountPerConfig || |
Stefan Lafon | b8c9aa8 | 2017-12-03 14:27:25 -0800 | [diff] [blame] | 86 | mAllAtomMatchers.size() > StatsdStats::kMaxMatcherCountPerConfig) { |
Yao Chen | b356151 | 2017-11-21 18:07:17 -0800 | [diff] [blame] | 87 | ALOGE("This config is too big! Reject!"); |
| 88 | mConfigValid = false; |
| 89 | } |
Yao Chen | f09569f | 2017-12-13 17:00:51 -0800 | [diff] [blame] | 90 | |
| 91 | // TODO: add alert size. |
| 92 | // no matter whether this config is valid, log it in the stats. |
| 93 | StatsdStats::getInstance().noteConfigReceived(key, mAllMetricProducers.size(), |
| 94 | mAllConditionTrackers.size(), |
| 95 | mAllAtomMatchers.size(), 0, mConfigValid); |
Yao Chen | 44cf27c | 2017-09-14 22:32:50 -0700 | [diff] [blame] | 96 | } |
| 97 | |
| 98 | MetricsManager::~MetricsManager() { |
Bookatz | d3606c7 | 2017-10-19 10:13:49 -0700 | [diff] [blame] | 99 | VLOG("~MetricsManager()"); |
Yao Chen | 44cf27c | 2017-09-14 22:32:50 -0700 | [diff] [blame] | 100 | } |
| 101 | |
Yao Chen | d10f7b1 | 2017-12-18 12:53:50 -0800 | [diff] [blame] | 102 | void MetricsManager::initLogSourceWhiteList() { |
| 103 | std::lock_guard<std::mutex> lock(mAllowedLogSourcesMutex); |
| 104 | mAllowedLogSources.clear(); |
| 105 | mAllowedLogSources.insert(mAllowedUid.begin(), mAllowedUid.end()); |
| 106 | |
| 107 | for (const auto& pkg : mAllowedPkg) { |
| 108 | auto uids = mUidMap->getAppUid(pkg); |
| 109 | mAllowedLogSources.insert(uids.begin(), uids.end()); |
| 110 | } |
| 111 | if (DEBUG) { |
| 112 | for (const auto& uid : mAllowedLogSources) { |
| 113 | VLOG("Allowed uid %d", uid); |
| 114 | } |
| 115 | } |
| 116 | } |
| 117 | |
Yao Chen | caf339d | 2017-10-06 16:01:10 -0700 | [diff] [blame] | 118 | bool MetricsManager::isConfigValid() const { |
| 119 | return mConfigValid; |
| 120 | } |
| 121 | |
Yao Chen | d10f7b1 | 2017-12-18 12:53:50 -0800 | [diff] [blame] | 122 | void MetricsManager::notifyAppUpgrade(const string& apk, const int uid, const int64_t version) { |
| 123 | // check if we care this package |
| 124 | if (std::find(mAllowedPkg.begin(), mAllowedPkg.end(), apk) == mAllowedPkg.end()) { |
| 125 | return; |
| 126 | } |
| 127 | // We will re-initialize the whole list because we don't want to keep the multi mapping of |
| 128 | // UID<->pkg inside MetricsManager to reduce the memory usage. |
| 129 | initLogSourceWhiteList(); |
| 130 | } |
| 131 | |
| 132 | void MetricsManager::notifyAppRemoved(const string& apk, const int uid) { |
| 133 | // check if we care this package |
| 134 | if (std::find(mAllowedPkg.begin(), mAllowedPkg.end(), apk) == mAllowedPkg.end()) { |
| 135 | return; |
| 136 | } |
| 137 | // We will re-initialize the whole list because we don't want to keep the multi mapping of |
| 138 | // UID<->pkg inside MetricsManager to reduce the memory usage. |
| 139 | initLogSourceWhiteList(); |
| 140 | } |
| 141 | |
| 142 | void MetricsManager::onUidMapReceived() { |
| 143 | if (mAllowedPkg.size() == 0) { |
| 144 | return; |
| 145 | } |
| 146 | initLogSourceWhiteList(); |
| 147 | } |
| 148 | |
Yangster-mac | 2087716 | 2017-12-22 17:19:39 -0800 | [diff] [blame] | 149 | void MetricsManager::onDumpReport(const uint64_t& dumpTimeStampNs, ConfigMetricsReport* report) { |
Yangster-mac | 94e197c | 2018-01-02 16:03:03 -0800 | [diff] [blame] | 150 | for (const auto& producer : mAllMetricProducers) { |
| 151 | if (mNoReportMetricIds.find(producer->getMetricId()) == mNoReportMetricIds.end()) { |
| 152 | producer->onDumpReport(dumpTimeStampNs, report->add_metrics()); |
| 153 | } |
Yangster-mac | 2087716 | 2017-12-22 17:19:39 -0800 | [diff] [blame] | 154 | } |
| 155 | } |
| 156 | |
Yao Chen | 884c8c1 | 2018-01-26 10:36:25 -0800 | [diff] [blame] | 157 | void MetricsManager::dumpStates(FILE* out, bool verbose) { |
| 158 | fprintf(out, "ConfigKey %s, allowed source:", mConfigKey.ToString().c_str()); |
| 159 | { |
| 160 | std::lock_guard<std::mutex> lock(mAllowedLogSourcesMutex); |
| 161 | for (const auto& source : mAllowedLogSources) { |
| 162 | fprintf(out, "%d ", source); |
| 163 | } |
| 164 | } |
| 165 | fprintf(out, "\n"); |
| 166 | for (const auto& producer : mAllMetricProducers) { |
| 167 | producer->dumpStates(out, verbose); |
| 168 | } |
| 169 | } |
| 170 | |
Yao Chen | 288c600 | 2017-12-12 13:43:18 -0800 | [diff] [blame] | 171 | void MetricsManager::onDumpReport(ProtoOutputStream* protoOutput) { |
Yao Chen | 729093d | 2017-10-16 10:33:26 -0700 | [diff] [blame] | 172 | VLOG("=========================Metric Reports Start=========================="); |
Yao Chen | 288c600 | 2017-12-12 13:43:18 -0800 | [diff] [blame] | 173 | uint64_t dumpTimeStampNs = time(nullptr) * NS_PER_SEC; |
Yao Chen | 729093d | 2017-10-16 10:33:26 -0700 | [diff] [blame] | 174 | // one StatsLogReport per MetricProduer |
Yangster-mac | 94e197c | 2018-01-02 16:03:03 -0800 | [diff] [blame] | 175 | for (const auto& producer : mAllMetricProducers) { |
| 176 | if (mNoReportMetricIds.find(producer->getMetricId()) == mNoReportMetricIds.end()) { |
| 177 | long long token = |
| 178 | protoOutput->start(FIELD_TYPE_MESSAGE | FIELD_COUNT_REPEATED | FIELD_ID_METRICS); |
| 179 | producer->onDumpReport(dumpTimeStampNs, protoOutput); |
| 180 | protoOutput->end(token); |
| 181 | } |
Yao Chen | 729093d | 2017-10-16 10:33:26 -0700 | [diff] [blame] | 182 | } |
| 183 | VLOG("=========================Metric Reports End=========================="); |
Yao Chen | 729093d | 2017-10-16 10:33:26 -0700 | [diff] [blame] | 184 | } |
| 185 | |
Yao Chen | 44cf27c | 2017-09-14 22:32:50 -0700 | [diff] [blame] | 186 | // Consume the stats log if it's interesting to this metric. |
Joe Onorato | c4dfae5 | 2017-10-17 23:38:21 -0700 | [diff] [blame] | 187 | void MetricsManager::onLogEvent(const LogEvent& event) { |
Yao Chen | caf339d | 2017-10-06 16:01:10 -0700 | [diff] [blame] | 188 | if (!mConfigValid) { |
| 189 | return; |
| 190 | } |
| 191 | |
Yao Chen | d10f7b1 | 2017-12-18 12:53:50 -0800 | [diff] [blame] | 192 | if (event.GetTagId() != android::util::APP_HOOK) { |
| 193 | std::lock_guard<std::mutex> lock(mAllowedLogSourcesMutex); |
| 194 | if (mAllowedLogSources.find(event.GetUid()) == mAllowedLogSources.end()) { |
| 195 | VLOG("log source %d not on the whitelist", event.GetUid()); |
| 196 | return; |
| 197 | } |
David Chen | daa9f3a | 2017-12-28 16:52:22 -0800 | [diff] [blame] | 198 | } else { // Check that app hook fields are valid. |
| 199 | // TODO: Find a way to make these checks easier to maintain if the app hooks get changed. |
| 200 | |
| 201 | // Label is 2nd from last field and must be from [0, 15]. |
| 202 | status_t err = NO_ERROR; |
| 203 | long label = event.GetLong(event.size()-1, &err); |
| 204 | if (err != NO_ERROR || label < 0 || label > 15) { |
| 205 | VLOG("App hook does not have valid label %ld", label); |
| 206 | return; |
| 207 | } |
| 208 | // The state must be from 0,3. This part of code must be manually updated. |
| 209 | long apphookState = event.GetLong(event.size(), &err); |
| 210 | if (err != NO_ERROR || apphookState < 0 || apphookState > 3) { |
| 211 | VLOG("App hook does not have valid state %ld", apphookState); |
| 212 | return; |
| 213 | } |
Yao Chen | d10f7b1 | 2017-12-18 12:53:50 -0800 | [diff] [blame] | 214 | } |
| 215 | |
Joe Onorato | c4dfae5 | 2017-10-17 23:38:21 -0700 | [diff] [blame] | 216 | int tagId = event.GetTagId(); |
Yao Chen | 5154a379 | 2017-10-30 22:57:06 -0700 | [diff] [blame] | 217 | uint64_t eventTime = event.GetTimestampNs(); |
Yao Chen | 44cf27c | 2017-09-14 22:32:50 -0700 | [diff] [blame] | 218 | if (mTagIds.find(tagId) == mTagIds.end()) { |
| 219 | // not interesting... |
| 220 | return; |
| 221 | } |
Yao Chen | 44cf27c | 2017-09-14 22:32:50 -0700 | [diff] [blame] | 222 | |
Stefan Lafon | b8c9aa8 | 2017-12-03 14:27:25 -0800 | [diff] [blame] | 223 | vector<MatchingState> matcherCache(mAllAtomMatchers.size(), MatchingState::kNotComputed); |
Yao Chen | caf339d | 2017-10-06 16:01:10 -0700 | [diff] [blame] | 224 | |
Stefan Lafon | b8c9aa8 | 2017-12-03 14:27:25 -0800 | [diff] [blame] | 225 | for (auto& matcher : mAllAtomMatchers) { |
| 226 | matcher->onLogEvent(event, mAllAtomMatchers, matcherCache); |
Yao Chen | 44cf27c | 2017-09-14 22:32:50 -0700 | [diff] [blame] | 227 | } |
| 228 | |
Yao Chen | caf339d | 2017-10-06 16:01:10 -0700 | [diff] [blame] | 229 | // A bitmap to see which ConditionTracker needs to be re-evaluated. |
| 230 | vector<bool> conditionToBeEvaluated(mAllConditionTrackers.size(), false); |
| 231 | |
| 232 | for (const auto& pair : mTrackerToConditionMap) { |
| 233 | if (matcherCache[pair.first] == MatchingState::kMatched) { |
| 234 | const auto& conditionList = pair.second; |
| 235 | for (const int conditionIndex : conditionList) { |
| 236 | conditionToBeEvaluated[conditionIndex] = true; |
| 237 | } |
| 238 | } |
| 239 | } |
| 240 | |
| 241 | vector<ConditionState> conditionCache(mAllConditionTrackers.size(), |
| 242 | ConditionState::kNotEvaluated); |
| 243 | // A bitmap to track if a condition has changed value. |
| 244 | vector<bool> changedCache(mAllConditionTrackers.size(), false); |
| 245 | for (size_t i = 0; i < mAllConditionTrackers.size(); i++) { |
| 246 | if (conditionToBeEvaluated[i] == false) { |
| 247 | continue; |
| 248 | } |
Yao Chen | caf339d | 2017-10-06 16:01:10 -0700 | [diff] [blame] | 249 | sp<ConditionTracker>& condition = mAllConditionTrackers[i]; |
| 250 | condition->evaluateCondition(event, matcherCache, mAllConditionTrackers, conditionCache, |
Yao Chen | 967b205 | 2017-11-07 16:36:43 -0800 | [diff] [blame] | 251 | changedCache); |
Yao Chen | 729093d | 2017-10-16 10:33:26 -0700 | [diff] [blame] | 252 | } |
| 253 | |
| 254 | for (size_t i = 0; i < mAllConditionTrackers.size(); i++) { |
Yao Chen | 967b205 | 2017-11-07 16:36:43 -0800 | [diff] [blame] | 255 | if (changedCache[i] == false) { |
Yao Chen | 729093d | 2017-10-16 10:33:26 -0700 | [diff] [blame] | 256 | continue; |
| 257 | } |
| 258 | auto pair = mConditionToMetricMap.find(i); |
| 259 | if (pair != mConditionToMetricMap.end()) { |
| 260 | auto& metricList = pair->second; |
| 261 | for (auto metricIndex : metricList) { |
| 262 | // metric cares about non sliced condition, and it's changed. |
| 263 | // Push the new condition to it directly. |
Yao Chen | 967b205 | 2017-11-07 16:36:43 -0800 | [diff] [blame] | 264 | if (!mAllMetricProducers[metricIndex]->isConditionSliced()) { |
Yao Chen | 5154a379 | 2017-10-30 22:57:06 -0700 | [diff] [blame] | 265 | mAllMetricProducers[metricIndex]->onConditionChanged(conditionCache[i], |
| 266 | eventTime); |
Yao Chen | 729093d | 2017-10-16 10:33:26 -0700 | [diff] [blame] | 267 | // metric cares about sliced conditions, and it may have changed. Send |
| 268 | // notification, and the metric can query the sliced conditions that are |
| 269 | // interesting to it. |
Yangster | f2bee6f | 2017-11-29 12:01:05 -0800 | [diff] [blame] | 270 | } else { |
Yao Chen | 5154a379 | 2017-10-30 22:57:06 -0700 | [diff] [blame] | 271 | mAllMetricProducers[metricIndex]->onSlicedConditionMayChange(eventTime); |
Yao Chen | 44cf27c | 2017-09-14 22:32:50 -0700 | [diff] [blame] | 272 | } |
Yao Chen | caf339d | 2017-10-06 16:01:10 -0700 | [diff] [blame] | 273 | } |
| 274 | } |
| 275 | } |
| 276 | |
Stefan Lafon | b8c9aa8 | 2017-12-03 14:27:25 -0800 | [diff] [blame] | 277 | // For matched AtomMatchers, tell relevant metrics that a matched event has come. |
| 278 | for (size_t i = 0; i < mAllAtomMatchers.size(); i++) { |
Yao Chen | caf339d | 2017-10-06 16:01:10 -0700 | [diff] [blame] | 279 | if (matcherCache[i] == MatchingState::kMatched) { |
Yao Chen | b356151 | 2017-11-21 18:07:17 -0800 | [diff] [blame] | 280 | StatsdStats::getInstance().noteMatcherMatched(mConfigKey, |
Yangster-mac | 94e197c | 2018-01-02 16:03:03 -0800 | [diff] [blame] | 281 | mAllAtomMatchers[i]->getId()); |
Yao Chen | caf339d | 2017-10-06 16:01:10 -0700 | [diff] [blame] | 282 | auto pair = mTrackerToMetricMap.find(i); |
| 283 | if (pair != mTrackerToMetricMap.end()) { |
| 284 | auto& metricList = pair->second; |
| 285 | for (const int metricIndex : metricList) { |
Chenjie Yu | b3dda41 | 2017-10-24 13:41:59 -0700 | [diff] [blame] | 286 | // pushed metrics are never scheduled pulls |
Chenjie Yu | a7259ab | 2017-12-10 08:31:05 -0800 | [diff] [blame] | 287 | mAllMetricProducers[metricIndex]->onMatchedLogEvent(i, event); |
Yao Chen | caf339d | 2017-10-06 16:01:10 -0700 | [diff] [blame] | 288 | } |
Yao Chen | 44cf27c | 2017-09-14 22:32:50 -0700 | [diff] [blame] | 289 | } |
| 290 | } |
| 291 | } |
| 292 | } |
| 293 | |
Yangster-mac | e2cd6d5 | 2017-11-09 20:38:30 -0800 | [diff] [blame] | 294 | void MetricsManager::onAnomalyAlarmFired(const uint64_t timestampNs, |
Bookatz | cc5adef2 | 2017-11-21 14:36:23 -0800 | [diff] [blame] | 295 | unordered_set<sp<const AnomalyAlarm>, SpHash<AnomalyAlarm>>& anomalySet) { |
Yangster-mac | e2cd6d5 | 2017-11-09 20:38:30 -0800 | [diff] [blame] | 296 | for (const auto& itr : mAllAnomalyTrackers) { |
Bookatz | cc5adef2 | 2017-11-21 14:36:23 -0800 | [diff] [blame] | 297 | itr->informAlarmsFired(timestampNs, anomalySet); |
Yangster-mac | e2cd6d5 | 2017-11-09 20:38:30 -0800 | [diff] [blame] | 298 | } |
| 299 | } |
| 300 | |
| 301 | void MetricsManager::setAnomalyMonitor(const sp<AnomalyMonitor>& anomalyMonitor) { |
| 302 | for (auto& itr : mAllAnomalyTrackers) { |
| 303 | itr->setAnomalyMonitor(anomalyMonitor); |
| 304 | } |
| 305 | } |
| 306 | |
yro | 69007c8 | 2017-10-26 20:42:57 -0700 | [diff] [blame] | 307 | // Returns the total byte size of all metrics managed by a single config source. |
| 308 | size_t MetricsManager::byteSize() { |
| 309 | size_t totalSize = 0; |
| 310 | for (auto metricProducer : mAllMetricProducers) { |
| 311 | totalSize += metricProducer->byteSize(); |
| 312 | } |
| 313 | return totalSize; |
| 314 | } |
| 315 | |
Yao Chen | 44cf27c | 2017-09-14 22:32:50 -0700 | [diff] [blame] | 316 | } // namespace statsd |
| 317 | } // namespace os |
| 318 | } // namespace android |