Add no more than 20 timestamps for a config in StatsdStats.
To avoid the array to grow unboundedly.
Test: added unit tests.
Change-Id: I3c4823b2a89bb69428d81b9fe348e7ea9aba24c7
diff --git a/cmds/statsd/src/guardrail/StatsdStats.h b/cmds/statsd/src/guardrail/StatsdStats.h
index 6fd9e4b..451144f 100644
--- a/cmds/statsd/src/guardrail/StatsdStats.h
+++ b/cmds/statsd/src/guardrail/StatsdStats.h
@@ -43,6 +43,8 @@
const static int kMaxMetricCountPerConfig = 300;
const static int kMaxMatcherCountPerConfig = 500;
+ const static int kMaxTimestampCount = 20;
+
/**
* Report a new config has been received and report the static stats about the config.
*
@@ -162,11 +164,18 @@
void addSubStatsToConfig(const ConfigKey& key, StatsdStatsReport_ConfigStats& configStats);
+ void noteDataDropped(const ConfigKey& key, int32_t timeSec);
+
+ void noteMetricsReportSent(const ConfigKey& key, int32_t timeSec);
+
+ void noteBroadcastSent(const ConfigKey& key, int32_t timeSec);
+
FRIEND_TEST(StatsdStatsTest, TestValidConfigAdd);
FRIEND_TEST(StatsdStatsTest, TestInvalidConfigAdd);
FRIEND_TEST(StatsdStatsTest, TestConfigRemove);
FRIEND_TEST(StatsdStatsTest, TestSubStats);
FRIEND_TEST(StatsdStatsTest, TestAtomLog);
+ FRIEND_TEST(StatsdStatsTest, TestTimestampThreshold);
};
} // namespace statsd