Support sliced condition change in GaugeMetric
TODO: We need CTS to verify the behavior.
Bug: 73958484
Test: statsd_test
Change-Id: I56406983ddede12bc6a2e12188693a0c51ccae5c
diff --git a/cmds/statsd/src/condition/SimpleConditionTracker.cpp b/cmds/statsd/src/condition/SimpleConditionTracker.cpp
index 73efb39..87104a3 100644
--- a/cmds/statsd/src/condition/SimpleConditionTracker.cpp
+++ b/cmds/statsd/src/condition/SimpleConditionTracker.cpp
@@ -289,9 +289,15 @@
// The event doesn't match this condition. So we just report existing condition values.
conditionChangedCache[mIndex] = false;
if (mSliced) {
- // if the condition result is sliced. metrics won't directly get value from the
- // cache, so just set any value other than kNotEvaluated.
+ // if the condition result is sliced. The overall condition is true if any of the sliced
+ // condition is true
conditionCache[mIndex] = mInitialValue;
+ for (const auto& slicedCondition : mSlicedConditionState) {
+ if (slicedCondition.second > 0) {
+ conditionCache[mIndex] = ConditionState::kTrue;
+ break;
+ }
+ }
} else {
const auto& itr = mSlicedConditionState.find(DEFAULT_DIMENSION_KEY);
if (itr == mSlicedConditionState.end()) {