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

Commit c9dad09a authored by Tej Singh's avatar Tej Singh Committed by Android (Google) Code Review
Browse files

Merge "Improve statsdstats logging for pulled atoms" into rvc-dev

parents 9bec3e33 873e91a1
Loading
Loading
Loading
Loading
+1 −0
Original line number 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.
    Status status = mCallback->onPullAtom(mTagId, resultReceiver);
    if (!status.isOk()) {
        StatsdStats::getInstance().notePullBinderCallFailed(mTagId);
        return false;
    }

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

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

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

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

void StatsdStats::noteStatsCompanionPullFailed(int atomId) {
void StatsdStats::notePullUidProviderNotFound(int atomId) {
    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);
    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) {
@@ -608,6 +613,7 @@ void StatsdStats::resetInternalLocked() {
    for (auto& pullStats : mPulledAtomStats) {
        pullStats.second.totalPull = 0;
        pullStats.second.totalPullFromCache = 0;
        pullStats.second.minPullIntervalSec = LONG_MAX;
        pullStats.second.avgPullTimeNs = 0;
        pullStats.second.maxPullTimeNs = 0;
        pullStats.second.numPullTime = 0;
@@ -617,9 +623,13 @@ void StatsdStats::resetInternalLocked() {
        pullStats.second.dataError = 0;
        pullStats.second.pullTimeout = 0;
        pullStats.second.pullExceedMaxDelay = 0;
        pullStats.second.pullFailed = 0;
        pullStats.second.pullUidProviderNotFound = 0;
        pullStats.second.pullerNotFound = 0;
        pullStats.second.registeredCount = 0;
        pullStats.second.unregisteredCount = 0;
        pullStats.second.atomErrorCount = 0;
        pullStats.second.binderCallFailCount = 0;
    }
    mAtomMetricStats.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 "
                "nanos)%lld, "
                "  (max pull delay nanos)%lld, (data error)%ld\n"
                "  (pull timeout)%ld, (pull exceed max delay)%ld\n"
                "  (registered count) %ld, (unregistered count) %ld\n"
                "  (pull timeout)%ld, (pull exceed max delay)%ld"
                "  (no uid provider count)%ld, (no puller found count)%ld\n"
                "  (registered count) %ld, (unregistered count) %ld"
                "  (atom error count) %d\n",
                (int)pair.first, (long)pair.second.totalPull, (long)pair.second.totalPullFromCache,
                (long)pair.second.pullFailed, (long)pair.second.minPullIntervalSec,
                (long long)pair.second.avgPullTimeNs, (long long)pair.second.maxPullTimeNs,
                (long long)pair.second.avgPullDelayNs, (long long)pair.second.maxPullDelayNs,
                pair.second.dataError, pair.second.pullTimeout, pair.second.pullExceedMaxDelay,
                pair.second.pullUidProviderNotFound, pair.second.pullerNotFound,
                pair.second.registeredCount, pair.second.unregisteredCount,
                pair.second.atomErrorCount);
    }
+19 −9
Original line number Diff line number Diff line
@@ -371,21 +371,30 @@ public:
                     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);

    /**
     * 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
     * transaction. This can happen when StatsCompanionService returns too
     * much data (the max Binder parcel size is 1MB)
     * Records that the pull has failed due to the outgoing binder call failing.
     */
    void noteStatsCompanionPullBinderTransactionFailed(int atomId);
    void notePullBinderCallFailed(int atomId);

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

    typedef struct {
Loading