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

Commit 873e91a1 authored by Tej Singh's avatar Tej Singh
Browse files

Improve statsdstats logging for pulled atoms

1. remove old statscompanion counters
2. add outgoing binder call fail counts
3. Add additional pull failure cases
 a. No pull uid provider (If a config doesn't register properly)
 b. Puller not found - either because it was not registered or because
the client did not specify the correct uids
4. Make metrics own logging pull delays - these were getting overcounted
since both the PullerManager and ValueMetricProducer were logging pull
delays.
5. Move noteEmptyPull to StatsPuller for more uniform logging, instead
of it just being logged in value metric producer.

Test: m statsd
Bug: 154056912
Change-Id: Ia373003905ee44d3b7b37b2bfa1e1d6268250070
parent 5a619092
Loading
Loading
Loading
Loading
+1 −0
Original line number Original line Diff line number Diff line
@@ -86,6 +86,7 @@ bool StatsCallbackPuller::PullInternal(vector<shared_ptr<LogEvent>>* data) {
    // in unit tests. In process calls are not oneway.
    // in unit tests. In process calls are not oneway.
    Status status = mCallback->onPullAtom(mTagId, resultReceiver);
    Status status = mCallback->onPullAtom(mTagId, resultReceiver);
    if (!status.isOk()) {
    if (!status.isOk()) {
        StatsdStats::getInstance().notePullBinderCallFailed(mTagId);
        return false;
        return false;
    }
    }


+5 −0
Original line number Original line Diff line number Diff line
@@ -82,6 +82,11 @@ bool StatsPuller::Pull(std::vector<std::shared_ptr<LogEvent>>* data) {
        mapAndMergeIsolatedUidsToHostUid(mCachedData, mUidMap, mTagId, mAdditiveFields);
        mapAndMergeIsolatedUidsToHostUid(mCachedData, mUidMap, mTagId, mAdditiveFields);
    }
    }


    if (mCachedData.empty()) {
        VLOG("Data pulled is empty");
        StatsdStats::getInstance().noteEmptyData(mTagId);
    }

    (*data) = mCachedData;
    (*data) = mCachedData;
    return mHasGoodData;
    return mHasGoodData;
}
}
+4 −4
Original line number Original line Diff line number Diff line
@@ -111,12 +111,14 @@ bool StatsPullerManager::PullLocked(int tagId, const ConfigKey& configKey,
        if (uidProviderIt == mPullUidProviders.end()) {
        if (uidProviderIt == mPullUidProviders.end()) {
            ALOGE("Error pulling tag %d. No pull uid provider for config key %s", tagId,
            ALOGE("Error pulling tag %d. No pull uid provider for config key %s", tagId,
                  configKey.ToString().c_str());
                  configKey.ToString().c_str());
            StatsdStats::getInstance().notePullUidProviderNotFound(tagId);
            return false;
            return false;
        }
        }
        sp<PullUidProvider> pullUidProvider = uidProviderIt->second.promote();
        sp<PullUidProvider> pullUidProvider = uidProviderIt->second.promote();
        if (pullUidProvider == nullptr) {
        if (pullUidProvider == nullptr) {
            ALOGE("Error pulling tag %d, pull uid provider for config %s is gone.", tagId,
            ALOGE("Error pulling tag %d, pull uid provider for config %s is gone.", tagId,
                  configKey.ToString().c_str());
                  configKey.ToString().c_str());
            StatsdStats::getInstance().notePullUidProviderNotFound(tagId);
            return false;
            return false;
        }
        }
        uids = pullUidProvider->getPullAtomUids(tagId);
        uids = pullUidProvider->getPullAtomUids(tagId);
@@ -140,6 +142,7 @@ bool StatsPullerManager::PullLocked(int tagId, const vector<int32_t>& uids,
                return ret;
                return ret;
            }
            }
        }
        }
        StatsdStats::getInstance().notePullerNotFound(tagId);
        ALOGW("StatsPullerManager: Unknown tagId %d", tagId);
        ALOGW("StatsPullerManager: Unknown tagId %d", tagId);
        return false;  // Return early since we don't know what to pull.
        return false;  // Return early since we don't know what to pull.
    } else {
    } else {
@@ -288,10 +291,7 @@ void StatsPullerManager::OnAlarmFired(int64_t elapsedTimeNs) {
    for (const auto& pullInfo : needToPull) {
    for (const auto& pullInfo : needToPull) {
        vector<shared_ptr<LogEvent>> data;
        vector<shared_ptr<LogEvent>> data;
        bool pullSuccess = PullLocked(pullInfo.first->atomTag, pullInfo.first->configKey, &data);
        bool pullSuccess = PullLocked(pullInfo.first->atomTag, pullInfo.first->configKey, &data);
        if (pullSuccess) {
        if (!pullSuccess) {
            StatsdStats::getInstance().notePullDelay(pullInfo.first->atomTag,
                                                     getElapsedRealtimeNs() - elapsedTimeNs);
        } else {
            VLOG("pull failed at %lld, will try again later", (long long)elapsedTimeNs);
            VLOG("pull failed at %lld, will try again later", (long long)elapsedTimeNs);
        }
        }


+18 −6
Original line number Original line Diff line number Diff line
@@ -472,14 +472,19 @@ void StatsdStats::notePullFailed(int atomId) {
    mPulledAtomStats[atomId].pullFailed++;
    mPulledAtomStats[atomId].pullFailed++;
}
}


void StatsdStats::noteStatsCompanionPullFailed(int atomId) {
void StatsdStats::notePullUidProviderNotFound(int atomId) {
    lock_guard<std::mutex> lock(mLock);
    lock_guard<std::mutex> lock(mLock);
    mPulledAtomStats[atomId].statsCompanionPullFailed++;
    mPulledAtomStats[atomId].pullUidProviderNotFound++;
}
}


void StatsdStats::noteStatsCompanionPullBinderTransactionFailed(int atomId) {
void StatsdStats::notePullerNotFound(int atomId) {
    lock_guard<std::mutex> lock(mLock);
    lock_guard<std::mutex> lock(mLock);
    mPulledAtomStats[atomId].statsCompanionPullBinderTransactionFailed++;
    mPulledAtomStats[atomId].pullerNotFound++;
}

void StatsdStats::notePullBinderCallFailed(int atomId) {
    lock_guard<std::mutex> lock(mLock);
    mPulledAtomStats[atomId].binderCallFailCount++;
}
}


void StatsdStats::noteEmptyData(int atomId) {
void StatsdStats::noteEmptyData(int atomId) {
@@ -608,6 +613,7 @@ void StatsdStats::resetInternalLocked() {
    for (auto& pullStats : mPulledAtomStats) {
    for (auto& pullStats : mPulledAtomStats) {
        pullStats.second.totalPull = 0;
        pullStats.second.totalPull = 0;
        pullStats.second.totalPullFromCache = 0;
        pullStats.second.totalPullFromCache = 0;
        pullStats.second.minPullIntervalSec = LONG_MAX;
        pullStats.second.avgPullTimeNs = 0;
        pullStats.second.avgPullTimeNs = 0;
        pullStats.second.maxPullTimeNs = 0;
        pullStats.second.maxPullTimeNs = 0;
        pullStats.second.numPullTime = 0;
        pullStats.second.numPullTime = 0;
@@ -617,9 +623,13 @@ void StatsdStats::resetInternalLocked() {
        pullStats.second.dataError = 0;
        pullStats.second.dataError = 0;
        pullStats.second.pullTimeout = 0;
        pullStats.second.pullTimeout = 0;
        pullStats.second.pullExceedMaxDelay = 0;
        pullStats.second.pullExceedMaxDelay = 0;
        pullStats.second.pullFailed = 0;
        pullStats.second.pullUidProviderNotFound = 0;
        pullStats.second.pullerNotFound = 0;
        pullStats.second.registeredCount = 0;
        pullStats.second.registeredCount = 0;
        pullStats.second.unregisteredCount = 0;
        pullStats.second.unregisteredCount = 0;
        pullStats.second.atomErrorCount = 0;
        pullStats.second.atomErrorCount = 0;
        pullStats.second.binderCallFailCount = 0;
    }
    }
    mAtomMetricStats.clear();
    mAtomMetricStats.clear();
    mActivationBroadcastGuardrailStats.clear();
    mActivationBroadcastGuardrailStats.clear();
@@ -764,14 +774,16 @@ void StatsdStats::dumpStats(int out) const {
                "  (average pull time nanos)%lld, (max pull time nanos)%lld, (average pull delay "
                "  (average pull time nanos)%lld, (max pull time nanos)%lld, (average pull delay "
                "nanos)%lld, "
                "nanos)%lld, "
                "  (max pull delay nanos)%lld, (data error)%ld\n"
                "  (max pull delay nanos)%lld, (data error)%ld\n"
                "  (pull timeout)%ld, (pull exceed max delay)%ld\n"
                "  (pull timeout)%ld, (pull exceed max delay)%ld"
                "  (registered count) %ld, (unregistered count) %ld\n"
                "  (no uid provider count)%ld, (no puller found count)%ld\n"
                "  (registered count) %ld, (unregistered count) %ld"
                "  (atom error count) %d\n",
                "  (atom error count) %d\n",
                (int)pair.first, (long)pair.second.totalPull, (long)pair.second.totalPullFromCache,
                (int)pair.first, (long)pair.second.totalPull, (long)pair.second.totalPullFromCache,
                (long)pair.second.pullFailed, (long)pair.second.minPullIntervalSec,
                (long)pair.second.pullFailed, (long)pair.second.minPullIntervalSec,
                (long long)pair.second.avgPullTimeNs, (long long)pair.second.maxPullTimeNs,
                (long long)pair.second.avgPullTimeNs, (long long)pair.second.maxPullTimeNs,
                (long long)pair.second.avgPullDelayNs, (long long)pair.second.maxPullDelayNs,
                (long long)pair.second.avgPullDelayNs, (long long)pair.second.maxPullDelayNs,
                pair.second.dataError, pair.second.pullTimeout, pair.second.pullExceedMaxDelay,
                pair.second.dataError, pair.second.pullTimeout, pair.second.pullExceedMaxDelay,
                pair.second.pullUidProviderNotFound, pair.second.pullerNotFound,
                pair.second.registeredCount, pair.second.unregisteredCount,
                pair.second.registeredCount, pair.second.unregisteredCount,
                pair.second.atomErrorCount);
                pair.second.atomErrorCount);
    }
    }
+19 −9
Original line number Original line Diff line number Diff line
@@ -371,21 +371,30 @@ public:
                     int32_t lastAtomTag, int32_t uid, int32_t pid);
                     int32_t lastAtomTag, int32_t uid, int32_t pid);


    /**
    /**
     * Records that the pull of an atom has failed
     * Records that the pull of an atom has failed. Eg, if the client indicated the pull failed, if
     * the pull timed out, or if the outgoing binder call failed.
     * This count will only increment if the puller was actually invoked.
     *
     * It does not include a pull not occurring due to not finding the appropriate
     * puller. These cases are covered in other counts.
     */
     */
    void notePullFailed(int atomId);
    void notePullFailed(int atomId);


    /**
    /**
     * Records that the pull of StatsCompanionService atom has failed
     * Records that the pull of an atom has failed due to not having a uid provider.
     */
    void notePullUidProviderNotFound(int atomId);

    /**
     * Records that the pull of an atom has failed due not finding a puller registered by a
     * trusted uid.
     */
     */
    void noteStatsCompanionPullFailed(int atomId);
    void notePullerNotFound(int atomId);


    /**
    /**
     * Records that the pull of a StatsCompanionService atom has failed due to a failed binder
     * Records that the pull has failed due to the outgoing binder call failing.
     * transaction. This can happen when StatsCompanionService returns too
     * much data (the max Binder parcel size is 1MB)
     */
     */
    void noteStatsCompanionPullBinderTransactionFailed(int atomId);
    void notePullBinderCallFailed(int atomId);


    /**
    /**
     * A pull with no data occurred
     * A pull with no data occurred
@@ -503,12 +512,13 @@ public:
        long pullTimeout = 0;
        long pullTimeout = 0;
        long pullExceedMaxDelay = 0;
        long pullExceedMaxDelay = 0;
        long pullFailed = 0;
        long pullFailed = 0;
        long statsCompanionPullFailed = 0;
        long pullUidProviderNotFound = 0;
        long statsCompanionPullBinderTransactionFailed = 0;
        long pullerNotFound = 0;
        long emptyData = 0;
        long emptyData = 0;
        long registeredCount = 0;
        long registeredCount = 0;
        long unregisteredCount = 0;
        long unregisteredCount = 0;
        int32_t atomErrorCount = 0;
        int32_t atomErrorCount = 0;
        long binderCallFailCount = 0;
    } PulledAtomStats;
    } PulledAtomStats;


    typedef struct {
    typedef struct {
Loading