Split buckets on boot complete
Also clean up a bit of code on splitting on app upgrades
Piggy-backed off the app upgrade tests, adding parameterized tests to
also test boot complete event.
Refactored some value metric test code to increase code reuse and
assertions.
Fixed a broken value metric test that had assertions commented out.
Refactored NamedLatch into MultiConditionTrigger to avoid creating a
thread before necessary.
Test: atest statsd_test
Test: push a simple test config, reboot, wait, get data. Made sure
the bucket was split
Bug: 144099206
Bug: 154511974
Change-Id: I73858b5db08e8cda762bd8091b30da8738d1fd88
diff --git a/cmds/statsd/src/StatsService.cpp b/cmds/statsd/src/StatsService.cpp
index ae7a8d0..f8cdcff 100644
--- a/cmds/statsd/src/StatsService.cpp
+++ b/cmds/statsd/src/StatsService.cpp
@@ -118,7 +118,8 @@
}
})),
mEventQueue(queue),
- mBootCompleteLatch({kBootCompleteTag, kUidMapReceivedTag, kAllPullersRegisteredTag}),
+ mBootCompleteTrigger({kBootCompleteTag, kUidMapReceivedTag, kAllPullersRegisteredTag},
+ [this]() { mProcessor->onStatsdInitCompleted(getElapsedRealtimeNs()); }),
mStatsCompanionServiceDeathRecipient(
AIBinder_DeathRecipient_new(StatsService::statsCompanionServiceDied)) {
mUidMap = UidMap::getInstance();
@@ -165,12 +166,6 @@
std::thread pushedEventThread([this] { readLogs(); });
pushedEventThread.detach();
}
-
- std::thread bootCompletedThread([this] {
- mBootCompleteLatch.wait();
- VLOG("In the boot completed thread");
- });
- bootCompletedThread.detach();
}
StatsService::~StatsService() {
@@ -946,7 +941,7 @@
packageNames,
installers);
- mBootCompleteLatch.countDown(kUidMapReceivedTag);
+ mBootCompleteTrigger.markComplete(kUidMapReceivedTag);
VLOG("StatsService::informAllUidData UidData proto parsed successfully.");
return Status::ok();
}
@@ -1066,7 +1061,7 @@
ENFORCE_UID(AID_SYSTEM);
VLOG("StatsService::bootCompleted was called");
- mBootCompleteLatch.countDown(kBootCompleteTag);
+ mBootCompleteTrigger.markComplete(kBootCompleteTag);
return Status::ok();
}
@@ -1235,7 +1230,7 @@
ENFORCE_UID(AID_SYSTEM);
VLOG("StatsService::allPullersFromBootRegistered was called");
- mBootCompleteLatch.countDown(kAllPullersRegisteredTag);
+ mBootCompleteTrigger.markComplete(kAllPullersRegisteredTag);
return Status::ok();
}