Statsd anomaly detection - fixes
Fixes a few items in AnomalyTracker, especially to do with what happens
when an anomaly alarm fires.
Test: unit tests still pass
Change-Id: Ia89bd617442e952e587336b890c3ca67430b5e21
diff --git a/cmds/statsd/src/StatsService.cpp b/cmds/statsd/src/StatsService.cpp
index 8b64f0d..31405b8 100644
--- a/cmds/statsd/src/StatsService.cpp
+++ b/cmds/statsd/src/StatsService.cpp
@@ -585,11 +585,10 @@
}
if (DEBUG) ALOGD("StatsService::informAnomalyAlarmFired succeeded");
- // TODO: check through all counters/timers and see if an anomaly has indeed occurred.
- uint64_t currentTimeNs = time(nullptr) * NS_PER_SEC;
+ uint64_t currentTimeSec = time(nullptr);
std::unordered_set<sp<const AnomalyAlarm>, SpHash<AnomalyAlarm>> anomalySet =
- mAnomalyMonitor->onAlarmFired(currentTimeNs);
- mProcessor->onAnomalyAlarmFired(currentTimeNs, anomalySet);
+ mAnomalyMonitor->popSoonerThan(static_cast<uint32_t>(currentTimeSec));
+ mProcessor->onAnomalyAlarmFired(currentTimeSec * NS_PER_SEC, anomalySet);
return Status::ok();
}