Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0a36f579 authored by Olivier Gaillard's avatar Olivier Gaillard
Browse files

Mark bucket as invalid when the condition was unknown at the start of

the bucket.

- since the condition was unknown, the bucket contains partial data.
- we need to do the same for other metrics

Bug: 124100912
Test: atest statsd_test
Change-Id: If803e28667c1e8a74d5b809bcab2eb54d1961f46
parent f9aa3044
Loading
Loading
Loading
Loading
+18 −14
Original line number Diff line number Diff line
@@ -355,12 +355,11 @@ void ValueMetricProducer::onConditionChangedLocked(const bool condition,

    flushIfNeededLocked(eventTimeNs);

    if (mCondition != ConditionState::kUnknown) {
        // Pull on condition changes.
        bool conditionChanged = mCondition != condition;
    bool unknownToFalse = mCondition == ConditionState::kUnknown
            && condition == ConditionState::kFalse;
        // We do not need to pull when we go from unknown to false.
    if (mIsPulled && conditionChanged && !unknownToFalse) {
        if (mIsPulled && conditionChanged) {
            pullAndMatchEventsLocked(eventTimeNs);
        }

@@ -369,7 +368,12 @@ void ValueMetricProducer::onConditionChangedLocked(const bool condition,
        if (mUseDiff && mCondition == ConditionState::kTrue && condition == ConditionState::kFalse) {
            resetBase();
        }

    } else {
        // If the condition was unknown, we mark the bucket as invalid since the bucket will contain
        // partial data. For instance, the condition change might happen close to the end of the
        // bucket and we might miss lots of data.
        invalidateCurrentBucket();
    }
    mCondition = condition ? ConditionState::kTrue : ConditionState::kFalse;
}

+2 −0
Original line number Diff line number Diff line
@@ -255,6 +255,8 @@ private:
    FRIEND_TEST(ValueMetricProducerTest, TestEmptyDataResetsBase_onConditionChanged);
    FRIEND_TEST(ValueMetricProducerTest, TestEmptyDataResetsBase_onBucketBoundary);
    FRIEND_TEST(ValueMetricProducerTest, TestPartialResetOnBucketBoundaries);
    FRIEND_TEST(ValueMetricProducerTest, TestBucketIncludingUnknownConditionIsInvalid);
    friend class ValueMetricProducerTestHelper;
};

}  // namespace statsd
+249 −345

File changed.

Preview size limit exceeded, changes collapsed.