Send Constellation P3A metrics early
This commit is contained in:
@@ -53,11 +53,9 @@ void ConstellationLogStore::UpdateMessage(const std::string& histogram_name,
|
||||
base::Value::Dict* epoch_dict = update->EnsureDict(epoch_key);
|
||||
epoch_dict->Set(histogram_name, msg);
|
||||
|
||||
if (current_epoch_ != epoch) {
|
||||
LogKey key(epoch, histogram_name);
|
||||
log_[key] = msg;
|
||||
unsent_entries_.insert(key);
|
||||
}
|
||||
LogKey key(epoch, histogram_name);
|
||||
log_[key] = msg;
|
||||
unsent_entries_.insert(key);
|
||||
}
|
||||
|
||||
void ConstellationLogStore::RemoveMessageIfExists(const LogKey& key) {
|
||||
@@ -168,11 +166,6 @@ void ConstellationLogStore::LoadPersistedUnsentLogs() {
|
||||
}
|
||||
uint8_t item_epoch = (uint8_t)parsed_epoch;
|
||||
|
||||
if (current_epoch_ == item_epoch) {
|
||||
// Do not load/send messages from the current epoch
|
||||
continue;
|
||||
}
|
||||
|
||||
if ((current_epoch_ - item_epoch) >= keep_epoch_count_) {
|
||||
// If epoch is too old, delete it
|
||||
epochs_to_remove.push_back(epoch_key);
|
||||
|
||||
@@ -73,16 +73,11 @@ class P3AConstellationLogStoreTest : public testing::Test {
|
||||
TestingPrefServiceSimple local_state;
|
||||
};
|
||||
|
||||
TEST_F(P3AConstellationLogStoreTest, CurrentEpochNoStage) {
|
||||
TEST_F(P3AConstellationLogStoreTest, CurrentEpochStaging) {
|
||||
log_store->SetCurrentEpoch(1);
|
||||
|
||||
ASSERT_FALSE(log_store->has_unsent_logs());
|
||||
ASSERT_FALSE(log_store->has_staged_log());
|
||||
|
||||
UpdateSomeMessages(1, 5);
|
||||
|
||||
ASSERT_FALSE(log_store->has_unsent_logs());
|
||||
ASSERT_FALSE(log_store->has_staged_log());
|
||||
UpdateSomeMessages(1, 8);
|
||||
ConsumeMessages(8);
|
||||
}
|
||||
|
||||
TEST_F(P3AConstellationLogStoreTest, PreviousEpochStaging) {
|
||||
@@ -113,7 +108,7 @@ TEST_F(P3AConstellationLogStoreTest, PreviousEpochsStaging) {
|
||||
UpdateSomeMessages(4, 10);
|
||||
|
||||
// Should consume messages from first three epochs
|
||||
ConsumeMessages(14);
|
||||
ConsumeMessages(24);
|
||||
}
|
||||
|
||||
TEST_F(P3AConstellationLogStoreTest, UpdatePreviousEpochMessage) {
|
||||
|
||||
@@ -312,8 +312,7 @@ TEST_F(P3AMessageManagerTest, UpdateLogsAndSendConstellation) {
|
||||
task_environment_.FastForwardBy(base::Seconds(kUploadIntervalSeconds * 100));
|
||||
|
||||
EXPECT_EQ(points_requests_made, 7U);
|
||||
// Should not send metrics, since they are in current epoch
|
||||
EXPECT_EQ(p3a_constellation_sent_messages.size(), 0U);
|
||||
EXPECT_EQ(p3a_constellation_sent_messages.size(), 7U);
|
||||
|
||||
ResetInterceptorStores();
|
||||
current_epoch++;
|
||||
|
||||
Reference in New Issue
Block a user