Add StatsdStats and guardrail.
+ StatsdStats is the global class that tracks the stats about statsd.
+ Added guardrail for classes that have a map which could potentially grow
unboundedly with the number of logs.
TODO: add unit tests & CTS for StatsdStats, and guardrail
add stats for pulled atoms.
Test: statsd_test
Change-Id: I0ea562de4dd3f6162f7923a9c193420b482c1d51
diff --git a/tools/stats_log_api_gen/main.cpp b/tools/stats_log_api_gen/main.cpp
index cca1294..423d028 100644
--- a/tools/stats_log_api_gen/main.cpp
+++ b/tools/stats_log_api_gen/main.cpp
@@ -18,6 +18,10 @@
namespace android {
namespace stats_log_api_gen {
+const int PULL_ATOM_START_ID = 1000;
+
+int maxPushedAtomId = 2;
+
using android::os::statsd::Atom;
// TODO: Support WorkSources
@@ -195,12 +199,18 @@
fprintf(out, " */\n");
char const* const comma = (i == atoms.decls.size() - 1) ? "" : ",";
fprintf(out, " %s = %d%s\n", constant.c_str(), atom->code, comma);
+ if (atom->code < PULL_ATOM_START_ID && atom->code > maxPushedAtomId) {
+ maxPushedAtomId = atom->code;
+ }
i++;
}
fprintf(out, "\n");
fprintf(out, "};\n");
fprintf(out, "\n");
+ fprintf(out, "const static int kMaxPushedAtomId = %d;\n\n",
+ maxPushedAtomId);
+
// Print write methods
fprintf(out, "//\n");
fprintf(out, "// Write methods\n");