summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Bookatz <bookatz@google.com> 2018-03-08 15:45:14 -0800
committer Bookatz <bookatz@google.com> 2018-03-09 11:09:51 -0800
commit423f753ea3c304805d278e0ccbcbf2ef5da311e9 (patch)
tree3e4c9d4a46c415a7e03f88757b4108fdbd7f1c0a
parent983c1e54e1ae651ffb4c0f1ce34a561624af6060 (diff)
statsd AnomalyDetection improvements
Re-add check to make sure that bad config won't cause duration anomaly detection to crash stastd Bug: 74399947 Test: manual Change-Id: Id175d233685c133ec3d4231272fe5708250dee6b
-rw-r--r--cmds/statsd/src/metrics/DurationMetricProducer.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/cmds/statsd/src/metrics/DurationMetricProducer.cpp b/cmds/statsd/src/metrics/DurationMetricProducer.cpp
index ac39662070d9..7f8c264c0e37 100644
--- a/cmds/statsd/src/metrics/DurationMetricProducer.cpp
+++ b/cmds/statsd/src/metrics/DurationMetricProducer.cpp
@@ -124,6 +124,13 @@ DurationMetricProducer::~DurationMetricProducer() {
sp<AnomalyTracker> DurationMetricProducer::addAnomalyTracker(
const Alert &alert, const sp<AlarmMonitor>& anomalyAlarmMonitor) {
std::lock_guard<std::mutex> lock(mMutex);
+ if (mAggregationType == DurationMetric_AggregationType_SUM) {
+ if (alert.trigger_if_sum_gt() > alert.num_buckets() * mBucketSizeNs) {
+ ALOGW("invalid alert for SUM: threshold (%f) > possible recordable value (%d x %lld)",
+ alert.trigger_if_sum_gt(), alert.num_buckets(), (long long)mBucketSizeNs);
+ return nullptr;
+ }
+ }
sp<DurationAnomalyTracker> anomalyTracker =
new DurationAnomalyTracker(alert, mConfigKey, anomalyAlarmMonitor);
if (anomalyTracker != nullptr) {