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 #define DEBUG false // STOPSHIP if true
17 #include "Log.h"
18
19 #include "MetricsManager.h"
20
21 #include <private/android_filesystem_config.h>
22
23 #include "CountMetricProducer.h"
24 #include "atoms_info.h"
25 #include "condition/CombinationConditionTracker.h"
26 #include "condition/SimpleConditionTracker.h"
27 #include "guardrail/StatsdStats.h"
28 #include "matchers/CombinationLogMatchingTracker.h"
29 #include "matchers/SimpleLogMatchingTracker.h"
30 #include "metrics_manager_util.h"
31 #include "stats_util.h"
32 #include "stats_log_util.h"
33 #include "statslog.h"
34
35 #include <private/android_filesystem_config.h>
36
37 using android::util::FIELD_COUNT_REPEATED;
38 using android::util::FIELD_TYPE_INT32;
39 using android::util::FIELD_TYPE_INT64;
40 using android::util::FIELD_TYPE_MESSAGE;
41 using android::util::FIELD_TYPE_STRING;
42 using android::util::ProtoOutputStream;
43
44 using std::set;
45 using std::string;
46 using std::vector;
47
48 namespace android {
49 namespace os {
50 namespace statsd {
51
52 const int FIELD_ID_METRICS = 1;
53 const int FIELD_ID_ANNOTATIONS = 7;
54 const int FIELD_ID_ANNOTATIONS_INT64 = 1;
55 const int FIELD_ID_ANNOTATIONS_INT32 = 2;
56
57 // for ActiveConfig
58 const int FIELD_ID_ACTIVE_CONFIG_ID = 1;
59 const int FIELD_ID_ACTIVE_CONFIG_UID = 2;
60 const int FIELD_ID_ACTIVE_CONFIG_METRIC = 3;
61
MetricsManager(const ConfigKey & key,const StatsdConfig & config,const int64_t timeBaseNs,const int64_t currentTimeNs,const sp<UidMap> & uidMap,const sp<StatsPullerManager> & pullerManager,const sp<AlarmMonitor> & anomalyAlarmMonitor,const sp<AlarmMonitor> & periodicAlarmMonitor)62 MetricsManager::MetricsManager(const ConfigKey& key, const StatsdConfig& config,
63 const int64_t timeBaseNs, const int64_t currentTimeNs,
64 const sp<UidMap>& uidMap,
65 const sp<StatsPullerManager>& pullerManager,
66 const sp<AlarmMonitor>& anomalyAlarmMonitor,
67 const sp<AlarmMonitor>& periodicAlarmMonitor)
68 : mConfigKey(key),
69 mUidMap(uidMap),
70 mTtlNs(config.has_ttl_in_seconds() ? config.ttl_in_seconds() * NS_PER_SEC : -1),
71 mTtlEndNs(-1),
72 mLastReportTimeNs(currentTimeNs),
73 mLastReportWallClockNs(getWallClockNs()),
74 mShouldPersistHistory(config.persist_locally()) {
75 // Init the ttl end timestamp.
76 refreshTtl(timeBaseNs);
77
78 mConfigValid = initStatsdConfig(
79 key, config, *uidMap, pullerManager, anomalyAlarmMonitor, periodicAlarmMonitor,
80 timeBaseNs, currentTimeNs, mTagIds, mAllAtomMatchers, mAllConditionTrackers,
81 mAllMetricProducers, mAllAnomalyTrackers, mAllPeriodicAlarmTrackers,
82 mConditionToMetricMap, mTrackerToMetricMap, mTrackerToConditionMap,
83 mActivationAtomTrackerToMetricMap, mDeactivationAtomTrackerToMetricMap,
84 mMetricIndexesWithActivation, mNoReportMetricIds);
85
86 mHashStringsInReport = config.hash_strings_in_metric_report();
87 mVersionStringsInReport = config.version_strings_in_metric_report();
88 mInstallerInReport = config.installer_in_metric_report();
89
90 if (config.allowed_log_source_size() == 0) {
91 mConfigValid = false;
92 ALOGE("Log source whitelist is empty! This config won't get any data. Suggest adding at "
93 "least AID_SYSTEM and AID_STATSD to the allowed_log_source field.");
94 } else {
95 for (const auto& source : config.allowed_log_source()) {
96 auto it = UidMap::sAidToUidMapping.find(source);
97 if (it != UidMap::sAidToUidMapping.end()) {
98 mAllowedUid.push_back(it->second);
99 } else {
100 mAllowedPkg.push_back(source);
101 }
102 }
103
104 if (mAllowedUid.size() + mAllowedPkg.size() > StatsdStats::kMaxLogSourceCount) {
105 ALOGE("Too many log sources. This is likely to be an error in the config.");
106 mConfigValid = false;
107 } else {
108 initLogSourceWhiteList();
109 }
110 }
111
112 // Store the sub-configs used.
113 for (const auto& annotation : config.annotation()) {
114 mAnnotations.emplace_back(annotation.field_int64(), annotation.field_int32());
115 }
116
117 // Guardrail. Reject the config if it's too big.
118 if (mAllMetricProducers.size() > StatsdStats::kMaxMetricCountPerConfig ||
119 mAllConditionTrackers.size() > StatsdStats::kMaxConditionCountPerConfig ||
120 mAllAtomMatchers.size() > StatsdStats::kMaxMatcherCountPerConfig) {
121 ALOGE("This config is too big! Reject!");
122 mConfigValid = false;
123 }
124 if (mAllAnomalyTrackers.size() > StatsdStats::kMaxAlertCountPerConfig) {
125 ALOGE("This config has too many alerts! Reject!");
126 mConfigValid = false;
127 }
128
129 mIsAlwaysActive = (mMetricIndexesWithActivation.size() != mAllMetricProducers.size()) ||
130 (mAllMetricProducers.size() == 0);
131 bool isActive = mIsAlwaysActive;
132 for (int metric : mMetricIndexesWithActivation) {
133 isActive |= mAllMetricProducers[metric]->isActive();
134 }
135 mIsActive = isActive;
136 VLOG("mIsActive is initialized to %d", mIsActive)
137
138 // no matter whether this config is valid, log it in the stats.
139 StatsdStats::getInstance().noteConfigReceived(
140 key, mAllMetricProducers.size(), mAllConditionTrackers.size(), mAllAtomMatchers.size(),
141 mAllAnomalyTrackers.size(), mAnnotations, mConfigValid);
142 // Check active
143 for (const auto& metric : mAllMetricProducers) {
144 if (metric->isActive()) {
145 mIsActive = true;
146 break;
147 }
148 }
149 }
150
~MetricsManager()151 MetricsManager::~MetricsManager() {
152 VLOG("~MetricsManager()");
153 }
154
initLogSourceWhiteList()155 void MetricsManager::initLogSourceWhiteList() {
156 std::lock_guard<std::mutex> lock(mAllowedLogSourcesMutex);
157 mAllowedLogSources.clear();
158 mAllowedLogSources.insert(mAllowedUid.begin(), mAllowedUid.end());
159
160 for (const auto& pkg : mAllowedPkg) {
161 auto uids = mUidMap->getAppUid(pkg);
162 mAllowedLogSources.insert(uids.begin(), uids.end());
163 }
164 if (DEBUG) {
165 for (const auto& uid : mAllowedLogSources) {
166 VLOG("Allowed uid %d", uid);
167 }
168 }
169 }
170
isConfigValid() const171 bool MetricsManager::isConfigValid() const {
172 return mConfigValid;
173 }
174
notifyAppUpgrade(const int64_t & eventTimeNs,const string & apk,const int uid,const int64_t version)175 void MetricsManager::notifyAppUpgrade(const int64_t& eventTimeNs, const string& apk, const int uid,
176 const int64_t version) {
177 // Inform all metric producers.
178 for (auto it : mAllMetricProducers) {
179 it->notifyAppUpgrade(eventTimeNs, apk, uid, version);
180 }
181 // check if we care this package
182 if (std::find(mAllowedPkg.begin(), mAllowedPkg.end(), apk) == mAllowedPkg.end()) {
183 return;
184 }
185 // We will re-initialize the whole list because we don't want to keep the multi mapping of
186 // UID<->pkg inside MetricsManager to reduce the memory usage.
187 initLogSourceWhiteList();
188 }
189
notifyAppRemoved(const int64_t & eventTimeNs,const string & apk,const int uid)190 void MetricsManager::notifyAppRemoved(const int64_t& eventTimeNs, const string& apk,
191 const int uid) {
192 // Inform all metric producers.
193 for (auto it : mAllMetricProducers) {
194 it->notifyAppRemoved(eventTimeNs, apk, uid);
195 }
196 // check if we care this package
197 if (std::find(mAllowedPkg.begin(), mAllowedPkg.end(), apk) == mAllowedPkg.end()) {
198 return;
199 }
200 // We will re-initialize the whole list because we don't want to keep the multi mapping of
201 // UID<->pkg inside MetricsManager to reduce the memory usage.
202 initLogSourceWhiteList();
203 }
204
onUidMapReceived(const int64_t & eventTimeNs)205 void MetricsManager::onUidMapReceived(const int64_t& eventTimeNs) {
206 // Purposefully don't inform metric producers on a new snapshot
207 // because we don't need to flush partial buckets.
208 // This occurs if a new user is added/removed or statsd crashes.
209 if (mAllowedPkg.size() == 0) {
210 return;
211 }
212 initLogSourceWhiteList();
213 }
214
dumpStates(FILE * out,bool verbose)215 void MetricsManager::dumpStates(FILE* out, bool verbose) {
216 fprintf(out, "ConfigKey %s, allowed source:", mConfigKey.ToString().c_str());
217 {
218 std::lock_guard<std::mutex> lock(mAllowedLogSourcesMutex);
219 for (const auto& source : mAllowedLogSources) {
220 fprintf(out, "%d ", source);
221 }
222 }
223 fprintf(out, "\n");
224 for (const auto& producer : mAllMetricProducers) {
225 producer->dumpStates(out, verbose);
226 }
227 }
228
dropData(const int64_t dropTimeNs)229 void MetricsManager::dropData(const int64_t dropTimeNs) {
230 for (const auto& producer : mAllMetricProducers) {
231 producer->dropData(dropTimeNs);
232 }
233 }
234
onDumpReport(const int64_t dumpTimeStampNs,const bool include_current_partial_bucket,const bool erase_data,const DumpLatency dumpLatency,std::set<string> * str_set,ProtoOutputStream * protoOutput)235 void MetricsManager::onDumpReport(const int64_t dumpTimeStampNs,
236 const bool include_current_partial_bucket,
237 const bool erase_data,
238 const DumpLatency dumpLatency,
239 std::set<string> *str_set,
240 ProtoOutputStream* protoOutput) {
241 VLOG("=========================Metric Reports Start==========================");
242 // one StatsLogReport per MetricProduer
243 for (const auto& producer : mAllMetricProducers) {
244 if (mNoReportMetricIds.find(producer->getMetricId()) == mNoReportMetricIds.end()) {
245 uint64_t token = protoOutput->start(
246 FIELD_TYPE_MESSAGE | FIELD_COUNT_REPEATED | FIELD_ID_METRICS);
247 if (mHashStringsInReport) {
248 producer->onDumpReport(dumpTimeStampNs, include_current_partial_bucket, erase_data,
249 dumpLatency, str_set, protoOutput);
250 } else {
251 producer->onDumpReport(dumpTimeStampNs, include_current_partial_bucket, erase_data,
252 dumpLatency, nullptr, protoOutput);
253 }
254 protoOutput->end(token);
255 } else {
256 producer->clearPastBuckets(dumpTimeStampNs);
257 }
258 }
259 for (const auto& annotation : mAnnotations) {
260 uint64_t token = protoOutput->start(FIELD_TYPE_MESSAGE | FIELD_COUNT_REPEATED |
261 FIELD_ID_ANNOTATIONS);
262 protoOutput->write(FIELD_TYPE_INT64 | FIELD_ID_ANNOTATIONS_INT64,
263 (long long)annotation.first);
264 protoOutput->write(FIELD_TYPE_INT32 | FIELD_ID_ANNOTATIONS_INT32, annotation.second);
265 protoOutput->end(token);
266 }
267
268 mLastReportTimeNs = dumpTimeStampNs;
269 mLastReportWallClockNs = getWallClockNs();
270 VLOG("=========================Metric Reports End==========================");
271 }
272
273
checkLogCredentials(const LogEvent & event)274 bool MetricsManager::checkLogCredentials(const LogEvent& event) {
275 if (android::util::AtomsInfo::kWhitelistedAtoms.find(event.GetTagId()) !=
276 android::util::AtomsInfo::kWhitelistedAtoms.end())
277 {
278 return true;
279 }
280 std::lock_guard<std::mutex> lock(mAllowedLogSourcesMutex);
281 if (mAllowedLogSources.find(event.GetUid()) == mAllowedLogSources.end()) {
282 VLOG("log source %d not on the whitelist", event.GetUid());
283 return false;
284 }
285 return true;
286 }
287
eventSanityCheck(const LogEvent & event)288 bool MetricsManager::eventSanityCheck(const LogEvent& event) {
289 if (event.GetTagId() == android::util::APP_BREADCRUMB_REPORTED) {
290 // Check that app breadcrumb reported fields are valid.
291 status_t err = NO_ERROR;
292
293 // Uid is 3rd from last field and must match the caller's uid,
294 // unless that caller is statsd itself (statsd is allowed to spoof uids).
295 long appHookUid = event.GetLong(event.size()-2, &err);
296 if (err != NO_ERROR ) {
297 VLOG("APP_BREADCRUMB_REPORTED had error when parsing the uid");
298 return false;
299 }
300 int32_t loggerUid = event.GetUid();
301 if (loggerUid != appHookUid && loggerUid != AID_STATSD) {
302 VLOG("APP_BREADCRUMB_REPORTED has invalid uid: claimed %ld but caller is %d",
303 appHookUid, loggerUid);
304 return false;
305 }
306
307 // The state must be from 0,3. This part of code must be manually updated.
308 long appHookState = event.GetLong(event.size(), &err);
309 if (err != NO_ERROR ) {
310 VLOG("APP_BREADCRUMB_REPORTED had error when parsing the state field");
311 return false;
312 } else if (appHookState < 0 || appHookState > 3) {
313 VLOG("APP_BREADCRUMB_REPORTED does not have valid state %ld", appHookState);
314 return false;
315 }
316 } else if (event.GetTagId() == android::util::DAVEY_OCCURRED) {
317 // Daveys can be logged from any app since they are logged in libs/hwui/JankTracker.cpp.
318 // Check that the davey duration is reasonable. Max length check is for privacy.
319 status_t err = NO_ERROR;
320
321 // Uid is the first field provided.
322 long jankUid = event.GetLong(1, &err);
323 if (err != NO_ERROR ) {
324 VLOG("Davey occurred had error when parsing the uid");
325 return false;
326 }
327 int32_t loggerUid = event.GetUid();
328 if (loggerUid != jankUid && loggerUid != AID_STATSD) {
329 VLOG("DAVEY_OCCURRED has invalid uid: claimed %ld but caller is %d", jankUid,
330 loggerUid);
331 return false;
332 }
333
334 long duration = event.GetLong(event.size(), &err);
335 if (err != NO_ERROR ) {
336 VLOG("Davey occurred had error when parsing the duration");
337 return false;
338 } else if (duration > 100000) {
339 VLOG("Davey duration is unreasonably long: %ld", duration);
340 return false;
341 }
342 }
343
344 return true;
345 }
346
347 // Consume the stats log if it's interesting to this metric.
onLogEvent(const LogEvent & event)348 void MetricsManager::onLogEvent(const LogEvent& event) {
349 if (!mConfigValid) {
350 return;
351 }
352
353 if (!checkLogCredentials(event)) {
354 return;
355 }
356
357 if (!eventSanityCheck(event)) {
358 return;
359 }
360
361 int tagId = event.GetTagId();
362 int64_t eventTimeNs = event.GetElapsedTimestampNs();
363
364 bool isActive = mIsAlwaysActive;
365
366 // Set of metrics that are still active after flushing.
367 unordered_set<int> activeMetricsIndices;
368
369 // Update state of all metrics w/ activation conditions as of eventTimeNs.
370 for (int metricIndex : mMetricIndexesWithActivation) {
371 const sp<MetricProducer>& metric = mAllMetricProducers[metricIndex];
372 metric->flushIfExpire(eventTimeNs);
373 if (metric->isActive()) {
374 // If this metric w/ activation condition is still active after
375 // flushing, remember it.
376 activeMetricsIndices.insert(metricIndex);
377 }
378 }
379
380 mIsActive = isActive || !activeMetricsIndices.empty();
381
382 if (mTagIds.find(tagId) == mTagIds.end()) {
383 // Not interesting...
384 return;
385 }
386
387 vector<MatchingState> matcherCache(mAllAtomMatchers.size(), MatchingState::kNotComputed);
388
389 // Evaluate all atom matchers.
390 for (auto& matcher : mAllAtomMatchers) {
391 matcher->onLogEvent(event, mAllAtomMatchers, matcherCache);
392 }
393
394 // Set of metrics that received an activation cancellation.
395 unordered_set<int> metricIndicesWithCanceledActivations;
396
397 // Determine which metric activations received a cancellation and cancel them.
398 for (const auto& it : mDeactivationAtomTrackerToMetricMap) {
399 if (matcherCache[it.first] == MatchingState::kMatched) {
400 for (int metricIndex : it.second) {
401 mAllMetricProducers[metricIndex]->cancelEventActivation(it.first);
402 metricIndicesWithCanceledActivations.insert(metricIndex);
403 }
404 }
405 }
406
407 // Determine whether any metrics are no longer active after cancelling metric activations.
408 for (const int metricIndex : metricIndicesWithCanceledActivations) {
409 const sp<MetricProducer>& metric = mAllMetricProducers[metricIndex];
410 metric->flushIfExpire(eventTimeNs);
411 if (!metric->isActive()) {
412 activeMetricsIndices.erase(metricIndex);
413 }
414 }
415
416 isActive |= !activeMetricsIndices.empty();
417
418
419 // Determine which metric activations should be turned on and turn them on
420 for (const auto& it : mActivationAtomTrackerToMetricMap) {
421 if (matcherCache[it.first] == MatchingState::kMatched) {
422 for (int metricIndex : it.second) {
423 mAllMetricProducers[metricIndex]->activate(it.first, eventTimeNs);
424 isActive |= mAllMetricProducers[metricIndex]->isActive();
425 }
426 }
427 }
428
429 mIsActive = isActive;
430
431 // A bitmap to see which ConditionTracker needs to be re-evaluated.
432 vector<bool> conditionToBeEvaluated(mAllConditionTrackers.size(), false);
433
434 for (const auto& pair : mTrackerToConditionMap) {
435 if (matcherCache[pair.first] == MatchingState::kMatched) {
436 const auto& conditionList = pair.second;
437 for (const int conditionIndex : conditionList) {
438 conditionToBeEvaluated[conditionIndex] = true;
439 }
440 }
441 }
442
443 vector<ConditionState> conditionCache(mAllConditionTrackers.size(),
444 ConditionState::kNotEvaluated);
445 // A bitmap to track if a condition has changed value.
446 vector<bool> changedCache(mAllConditionTrackers.size(), false);
447 for (size_t i = 0; i < mAllConditionTrackers.size(); i++) {
448 if (conditionToBeEvaluated[i] == false) {
449 continue;
450 }
451 sp<ConditionTracker>& condition = mAllConditionTrackers[i];
452 condition->evaluateCondition(event, matcherCache, mAllConditionTrackers, conditionCache,
453 changedCache);
454 }
455
456 for (size_t i = 0; i < mAllConditionTrackers.size(); i++) {
457 if (changedCache[i] == false) {
458 continue;
459 }
460 auto pair = mConditionToMetricMap.find(i);
461 if (pair != mConditionToMetricMap.end()) {
462 auto& metricList = pair->second;
463 for (auto metricIndex : metricList) {
464 // Metric cares about non sliced condition, and it's changed.
465 // Push the new condition to it directly.
466 if (!mAllMetricProducers[metricIndex]->isConditionSliced()) {
467 mAllMetricProducers[metricIndex]->onConditionChanged(conditionCache[i],
468 eventTimeNs);
469 // Metric cares about sliced conditions, and it may have changed. Send
470 // notification, and the metric can query the sliced conditions that are
471 // interesting to it.
472 } else {
473 mAllMetricProducers[metricIndex]->onSlicedConditionMayChange(conditionCache[i],
474 eventTimeNs);
475 }
476 }
477 }
478 }
479
480 // For matched AtomMatchers, tell relevant metrics that a matched event has come.
481 for (size_t i = 0; i < mAllAtomMatchers.size(); i++) {
482 if (matcherCache[i] == MatchingState::kMatched) {
483 StatsdStats::getInstance().noteMatcherMatched(mConfigKey,
484 mAllAtomMatchers[i]->getId());
485 auto pair = mTrackerToMetricMap.find(i);
486 if (pair != mTrackerToMetricMap.end()) {
487 auto& metricList = pair->second;
488 for (const int metricIndex : metricList) {
489 // pushed metrics are never scheduled pulls
490 mAllMetricProducers[metricIndex]->onMatchedLogEvent(i, event);
491 }
492 }
493 }
494 }
495 }
496
onAnomalyAlarmFired(const int64_t & timestampNs,unordered_set<sp<const InternalAlarm>,SpHash<InternalAlarm>> & alarmSet)497 void MetricsManager::onAnomalyAlarmFired(
498 const int64_t& timestampNs,
499 unordered_set<sp<const InternalAlarm>, SpHash<InternalAlarm>>& alarmSet) {
500 for (const auto& itr : mAllAnomalyTrackers) {
501 itr->informAlarmsFired(timestampNs, alarmSet);
502 }
503 }
504
onPeriodicAlarmFired(const int64_t & timestampNs,unordered_set<sp<const InternalAlarm>,SpHash<InternalAlarm>> & alarmSet)505 void MetricsManager::onPeriodicAlarmFired(
506 const int64_t& timestampNs,
507 unordered_set<sp<const InternalAlarm>, SpHash<InternalAlarm>>& alarmSet) {
508 for (const auto& itr : mAllPeriodicAlarmTrackers) {
509 itr->informAlarmsFired(timestampNs, alarmSet);
510 }
511 }
512
513 // Returns the total byte size of all metrics managed by a single config source.
byteSize()514 size_t MetricsManager::byteSize() {
515 size_t totalSize = 0;
516 for (const auto& metricProducer : mAllMetricProducers) {
517 totalSize += metricProducer->byteSize();
518 }
519 return totalSize;
520 }
521
loadActiveConfig(const ActiveConfig & config,int64_t currentTimeNs)522 void MetricsManager::loadActiveConfig(const ActiveConfig& config, int64_t currentTimeNs) {
523 if (config.metric_size() == 0) {
524 ALOGW("No active metric for config %s", mConfigKey.ToString().c_str());
525 return;
526 }
527
528 for (int i = 0; i < config.metric_size(); i++) {
529 const auto& activeMetric = config.metric(i);
530 for (int metricIndex : mMetricIndexesWithActivation) {
531 const auto& metric = mAllMetricProducers[metricIndex];
532 if (metric->getMetricId() == activeMetric.id()) {
533 VLOG("Setting active metric: %lld", (long long)metric->getMetricId());
534 metric->loadActiveMetric(activeMetric, currentTimeNs);
535 if (!mIsActive && metric->isActive()) {
536 StatsdStats::getInstance().noteActiveStatusChanged(mConfigKey,
537 /*activate=*/ true);
538 }
539 mIsActive |= metric->isActive();
540 }
541 }
542 }
543 }
544
writeActiveConfigToProtoOutputStream(int64_t currentTimeNs,const DumpReportReason reason,ProtoOutputStream * proto)545 void MetricsManager::writeActiveConfigToProtoOutputStream(
546 int64_t currentTimeNs, const DumpReportReason reason, ProtoOutputStream* proto) {
547 proto->write(FIELD_TYPE_INT64 | FIELD_ID_ACTIVE_CONFIG_ID, (long long)mConfigKey.GetId());
548 proto->write(FIELD_TYPE_INT32 | FIELD_ID_ACTIVE_CONFIG_UID, mConfigKey.GetUid());
549 for (int metricIndex : mMetricIndexesWithActivation) {
550 const auto& metric = mAllMetricProducers[metricIndex];
551 const uint64_t metricToken = proto->start(FIELD_TYPE_MESSAGE | FIELD_COUNT_REPEATED |
552 FIELD_ID_ACTIVE_CONFIG_METRIC);
553 metric->writeActiveMetricToProtoOutputStream(currentTimeNs, reason, proto);
554 proto->end(metricToken);
555 }
556 }
557
558
559
560
561 } // namespace statsd
562 } // namespace os
563 } // namespace android
564