diff options
author | Yangster-mac <yanglu@google.com> | 2018-05-17 15:52:51 -0700 |
---|---|---|
committer | Yangster-mac <yanglu@google.com> | 2018-05-18 10:39:50 -0700 |
commit | 1c58f04cd34291584b7bf2b45a54427e0ef650c8 (patch) | |
tree | dab5a4012531878d059e505525814ae09fa443f4 /cmds/statsd/src/metrics/MetricsManager.cpp | |
parent | 644c94f1251b57e9a08196fb660ab909e9afe5a8 (diff) |
Add a field in config to disable/enable the string hashing in metric report.
Statsd hashes (using its own hashing function) raw strings to reduce the
upload data size when there are duplicate strings in the report. And in cloud,
the clearcut translator would backfill the strings.
In a few droidfood users, we find the translator was unable to do that. While
debugging the root cause, we first decided to provide an option to disable
the hashing from the cloud.
Test: statsd unit test, CTS test, tested manually
BUG: b/79943763
Change-Id: If0359c8cf3f3cf83a2938db9ebf95ea7906f0b0c
Diffstat (limited to 'cmds/statsd/src/metrics/MetricsManager.cpp')
-rw-r--r-- | cmds/statsd/src/metrics/MetricsManager.cpp | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/cmds/statsd/src/metrics/MetricsManager.cpp b/cmds/statsd/src/metrics/MetricsManager.cpp index 2d14b05c8f5b..4fac0e1a141b 100644 --- a/cmds/statsd/src/metrics/MetricsManager.cpp +++ b/cmds/statsd/src/metrics/MetricsManager.cpp @@ -74,6 +74,8 @@ MetricsManager::MetricsManager(const ConfigKey& key, const StatsdConfig& config, mAllPeriodicAlarmTrackers, mConditionToMetricMap, mTrackerToMetricMap, mTrackerToConditionMap, mNoReportMetricIds); + mHashStringsInReport = config.hash_strings_in_metric_report(); + if (config.allowed_log_source_size() == 0) { mConfigValid = false; ALOGE("Log source whitelist is empty! This config won't get any data. Suggest adding at " @@ -201,8 +203,13 @@ void MetricsManager::onDumpReport(const int64_t dumpTimeStampNs, if (mNoReportMetricIds.find(producer->getMetricId()) == mNoReportMetricIds.end()) { uint64_t token = protoOutput->start( FIELD_TYPE_MESSAGE | FIELD_COUNT_REPEATED | FIELD_ID_METRICS); - producer->onDumpReport(dumpTimeStampNs, include_current_partial_bucket, str_set, - protoOutput); + if (mHashStringsInReport) { + producer->onDumpReport(dumpTimeStampNs, include_current_partial_bucket, str_set, + protoOutput); + } else { + producer->onDumpReport(dumpTimeStampNs, include_current_partial_bucket, nullptr, + protoOutput); + } protoOutput->end(token); } else { producer->clearPastBuckets(dumpTimeStampNs); |