Loading cmds/statsd/src/metrics/ValueMetricProducer.cpp +18 −14 Original line number Diff line number Diff line Loading @@ -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); } Loading @@ -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; } Loading cmds/statsd/src/metrics/ValueMetricProducer.h +2 −0 Original line number Diff line number Diff line Loading @@ -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 Loading cmds/statsd/tests/metrics/ValueMetricProducer_test.cpp +249 −345 File changed.Preview size limit exceeded, changes collapsed. Show changes Loading
cmds/statsd/src/metrics/ValueMetricProducer.cpp +18 −14 Original line number Diff line number Diff line Loading @@ -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); } Loading @@ -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; } Loading
cmds/statsd/src/metrics/ValueMetricProducer.h +2 −0 Original line number Diff line number Diff line Loading @@ -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 Loading
cmds/statsd/tests/metrics/ValueMetricProducer_test.cpp +249 −345 File changed.Preview size limit exceeded, changes collapsed. Show changes