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
This commit is contained in:
@@ -385,7 +385,11 @@ void StatsLogProcessor::onConfigMetricsReportLocked(const ConfigKey& key,
|
||||
// This skips the uid map if it's an empty config.
|
||||
if (it->second->getNumMetrics() > 0) {
|
||||
uint64_t uidMapToken = proto->start(FIELD_TYPE_MESSAGE | FIELD_ID_UID_MAP);
|
||||
mUidMap->appendUidMap(dumpTimeStampNs, key, &str_set, proto);
|
||||
if (it->second->hashStringInReport()) {
|
||||
mUidMap->appendUidMap(dumpTimeStampNs, key, &str_set, proto);
|
||||
} else {
|
||||
mUidMap->appendUidMap(dumpTimeStampNs, key, nullptr, proto);
|
||||
}
|
||||
proto->end(uidMapToken);
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -77,6 +77,10 @@ public:
|
||||
return mTtlNs <= 0 || timestampNs < mTtlEndNs;
|
||||
};
|
||||
|
||||
inline bool hashStringInReport() const {
|
||||
return mHashStringsInReport;
|
||||
};
|
||||
|
||||
void refreshTtl(const int64_t currentTimestampNs) {
|
||||
if (mTtlNs > 0) {
|
||||
mTtlEndNs = currentTimestampNs + mTtlNs;
|
||||
@@ -118,6 +122,8 @@ private:
|
||||
|
||||
bool mConfigValid = false;
|
||||
|
||||
bool mHashStringsInReport = false;
|
||||
|
||||
const int64_t mTtlNs;
|
||||
int64_t mTtlEndNs;
|
||||
|
||||
|
||||
@@ -364,6 +364,8 @@ message StatsdConfig {
|
||||
|
||||
optional int64 ttl_in_seconds = 15;
|
||||
|
||||
optional bool hash_strings_in_metric_report = 16 [default = true];
|
||||
|
||||
// Field number 1000 is reserved for later use.
|
||||
reserved 1000;
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user