summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Christine Tsai <tsaichristine@google.com> 2020-05-29 13:57:20 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2020-05-29 13:57:20 +0000
commit0d4555332787d342e96dbd1f5d08a9a4fba6ce43 (patch)
tree77b520429a7cb2ad36a9fc3e3c31defca1b421c0
parent8d3583e81ea5879602a32b857d3b266ce7d11603 (diff)
parent0f6c1bcbc9a3310dbd8bce02951a7c38a1c3633e (diff)
Merge "StateTracker handles active state changes" into rvc-dev
-rw-r--r--cmds/statsd/src/metrics/ValueMetricProducer.cpp5
-rw-r--r--cmds/statsd/src/metrics/duration_helper/OringDurationTracker.cpp5
2 files changed, 7 insertions, 3 deletions
diff --git a/cmds/statsd/src/metrics/ValueMetricProducer.cpp b/cmds/statsd/src/metrics/ValueMetricProducer.cpp
index dbec24bf3f6c..267834fdc5ae 100644
--- a/cmds/statsd/src/metrics/ValueMetricProducer.cpp
+++ b/cmds/statsd/src/metrics/ValueMetricProducer.cpp
@@ -187,8 +187,9 @@ void ValueMetricProducer::onStateChanged(int64_t eventTimeNs, int32_t atomId,
VLOG("ValueMetric %lld onStateChanged time %lld, State %d, key %s, %d -> %d",
(long long)mMetricId, (long long)eventTimeNs, atomId, primaryKey.toString().c_str(),
oldState.mValue.int_value, newState.mValue.int_value);
- // If condition is not true, we do not need to pull for this state change.
- if (mCondition != ConditionState::kTrue) {
+ // If condition is not true or metric is not active, we do not need to pull
+ // for this state change.
+ if (mCondition != ConditionState::kTrue || !mIsActive) {
return;
}
diff --git a/cmds/statsd/src/metrics/duration_helper/OringDurationTracker.cpp b/cmds/statsd/src/metrics/duration_helper/OringDurationTracker.cpp
index 19b2fe89989d..0d49bbc269a3 100644
--- a/cmds/statsd/src/metrics/duration_helper/OringDurationTracker.cpp
+++ b/cmds/statsd/src/metrics/duration_helper/OringDurationTracker.cpp
@@ -329,7 +329,10 @@ void OringDurationTracker::onConditionChanged(bool condition, const int64_t time
void OringDurationTracker::onStateChanged(const int64_t timestamp, const int32_t atomId,
const FieldValue& newState) {
- // If no keys are being tracked, update the current state key and return.
+ // Nothing needs to be done on a state change if we have not seen a start
+ // event, the metric is currently not active, or condition is false.
+ // For these cases, no keys are being tracked in mStarted, so update
+ // the current state key and return.
if (mStarted.empty()) {
updateCurrentStateKey(atomId, newState);
return;