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

Commit 6158952c authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Avoid reading logs that were processed before."

parents fa3ed754 8f42ba0e
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -74,7 +74,8 @@ StatsLogProcessor::StatsLogProcessor(const sp<UidMap>& uidMap,
      mAnomalyAlarmMonitor(anomalyAlarmMonitor),
      mPeriodicAlarmMonitor(periodicAlarmMonitor),
      mSendBroadcast(sendBroadcast),
      mTimeBaseSec(timeBaseSec) {
      mTimeBaseSec(timeBaseSec),
      mLastLogTimestamp(0) {
    StatsPullerManager statsPullerManager;
    statsPullerManager.SetTimeBaseSec(mTimeBaseSec);
}
@@ -144,9 +145,12 @@ void StatsLogProcessor::onIsolatedUidChangedEventLocked(const LogEvent& event) {
    }
}

// TODO: what if statsd service restarts? How do we know what logs are already processed before?
void StatsLogProcessor::OnLogEvent(LogEvent* event) {
    std::lock_guard<std::mutex> lock(mMetricsMutex);
    if (event->GetElapsedTimestampNs() < mLastLogTimestamp) {
        return;
    }
    mLastLogTimestamp = event->GetElapsedTimestampNs();
    StatsdStats::getInstance().noteAtomLogged(
        event->GetTagId(), event->GetElapsedTimestampNs() / NS_PER_SEC);

+2 −0
Original line number Diff line number Diff line
@@ -106,6 +106,8 @@ private:

    const long mTimeBaseSec;

    int64_t mLastLogTimestamp;

    long mLastPullerCacheClearTimeSec = 0;

    FRIEND_TEST(StatsLogProcessorTest, TestRateLimitByteSize);