Merge "Avoid reading logs that were processed before."

This commit is contained in:
TreeHugger Robot
2018-02-28 19:37:05 +00:00
committed by Android (Google) Code Review
2 changed files with 8 additions and 2 deletions

View File

@@ -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);

View File

@@ -106,6 +106,8 @@ private:
const long mTimeBaseSec;
int64_t mLastLogTimestamp;
long mLastPullerCacheClearTimeSec = 0;
FRIEND_TEST(StatsLogProcessorTest, TestRateLimitByteSize);