Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 02b40158 authored by Yangster-mac's avatar Yangster-mac Committed by android-build-merger
Browse files

Merge "Add a field in config to disable/enable the string hashing in metric report." into pi-dev

am: 76cb7fe2

Change-Id: I4bb331330c505396427bb72ff7b69c2b6653ba97
parents b3da3a96 76cb7fe2
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -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);
        if (it->second->hashStringInReport()) {
            mUidMap->appendUidMap(dumpTimeStampNs, key, &str_set, proto);
        } else {
            mUidMap->appendUidMap(dumpTimeStampNs, key, nullptr, proto);
        }
        proto->end(uidMapToken);
    }

+9 −2
Original line number Diff line number Diff line
@@ -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);
            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);
+6 −0
Original line number Diff line number Diff line
@@ -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;

+2 −0
Original line number Diff line number Diff line
@@ -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;
}
+491 −452

File changed.

Preview size limit exceeded, changes collapsed.