1/ Duration anomaly tracker with alarm.
2/ Init anomaly from config based on the public language.
3/ Unit tests for anomaly detection in count/gauge producer.
4/ Revisit the duration tracker logic.
Test: unit test passed.
Change-Id: I2423c0e0f05b1e37626954de9e749303423963f2
diff --git a/cmds/statsd/src/metrics/MetricProducer.h b/cmds/statsd/src/metrics/MetricProducer.h
index c7982a8..0f93744 100644
--- a/cmds/statsd/src/metrics/MetricProducer.h
+++ b/cmds/statsd/src/metrics/MetricProducer.h
@@ -17,6 +17,7 @@
#ifndef METRIC_PRODUCER_H
#define METRIC_PRODUCER_H
+#include "anomaly/AnomalyTracker.h"
#include "condition/ConditionWizard.h"
#include "matchers/matcher_util.h"
#include "packages/PackageInfoListener.h"
@@ -58,6 +59,7 @@
// This is called when the metric collecting is done, e.g., when there is a new configuration
// coming. MetricProducer should do the clean up, and dump existing data to dropbox.
virtual void finish() = 0;
+ virtual void flushIfNeeded(const uint64_t newEventTime) = 0;
// TODO: Pass a timestamp as a parameter in onDumpReport and update all its
// implementations.
@@ -72,6 +74,14 @@
// state.
virtual size_t byteSize() = 0;
+ void addAnomalyTracker(sp<AnomalyTracker> tracker) {
+ mAnomalyTrackers.push_back(tracker);
+ }
+
+ int64_t getBuckeSizeInNs() const {
+ return mBucketSizeNs;
+ }
+
protected:
const uint64_t mStartTimeNs;
@@ -97,6 +107,8 @@
std::vector<EventConditionLink> mConditionLinks;
+ std::vector<sp<AnomalyTracker>> mAnomalyTrackers;
+
/*
* Individual metrics can implement their own business logic here. All pre-processing is done.
*