Merge "Configurable data error action in value metric" into pi-dev am: 5ca38cafe8
am: 315211c74b
Change-Id: Iafca516e23b063bab59e751cecbea9ef9e25c1bd
diff --git a/cmds/statsd/src/metrics/ValueMetricProducer.cpp b/cmds/statsd/src/metrics/ValueMetricProducer.cpp
index df8763c..136fd14 100644
--- a/cmds/statsd/src/metrics/ValueMetricProducer.cpp
+++ b/cmds/statsd/src/metrics/ValueMetricProducer.cpp
@@ -87,7 +87,8 @@
mDimensionHardLimit(StatsdStats::kAtomDimensionKeySizeLimitMap.find(pullTagId) !=
StatsdStats::kAtomDimensionKeySizeLimitMap.end()
? StatsdStats::kAtomDimensionKeySizeLimitMap.at(pullTagId).second
- : StatsdStats::kDimensionKeySizeHardLimit) {
+ : StatsdStats::kDimensionKeySizeHardLimit),
+ mUseAbsoluteValueOnReset(metric.use_absolute_value_on_reset()) {
// TODO: valuemetric for pushed events may need unlimited bucket length
int64_t bucketSizeMills = 0;
if (metric.has_bucket()) {
@@ -393,15 +394,20 @@
}
} else {
// Generally we expect value to be monotonically increasing.
- // If not, there was a reset event. We take the absolute value as
- // diff in this case.
+ // If not, take absolute value or drop it, based on config.
if (interval.startUpdated) {
if (value >= interval.start) {
interval.sum += (value - interval.start);
+ interval.hasValue = true;
} else {
- interval.sum += value;
+ if (mUseAbsoluteValueOnReset) {
+ interval.sum += value;
+ interval.hasValue = true;
+ } else {
+ VLOG("Dropping data for atom %d, prev: %lld, now: %lld", mPullTagId,
+ (long long)interval.start, (long long)value);
+ }
}
- interval.hasValue = true;
interval.startUpdated = false;
} else {
VLOG("No start for matching end %lld", (long long)value);
diff --git a/cmds/statsd/src/metrics/ValueMetricProducer.h b/cmds/statsd/src/metrics/ValueMetricProducer.h
index 113be4b..0136ec1 100644
--- a/cmds/statsd/src/metrics/ValueMetricProducer.h
+++ b/cmds/statsd/src/metrics/ValueMetricProducer.h
@@ -164,6 +164,8 @@
const size_t mDimensionHardLimit;
+ const bool mUseAbsoluteValueOnReset;
+
FRIEND_TEST(ValueMetricProducerTest, TestNonDimensionalEvents);
FRIEND_TEST(ValueMetricProducerTest, TestEventsWithNonSlicedCondition);
FRIEND_TEST(ValueMetricProducerTest, TestPushedEventsWithUpgrade);
diff --git a/cmds/statsd/src/statsd_config.proto b/cmds/statsd/src/statsd_config.proto
index 849d5f6..eb77299 100644
--- a/cmds/statsd/src/statsd_config.proto
+++ b/cmds/statsd/src/statsd_config.proto
@@ -265,6 +265,8 @@
optional AggregationType aggregation_type = 8 [default = SUM];
optional int64 min_bucket_size_nanos = 10;
+
+ optional bool use_absolute_value_on_reset = 11 [default = false];
}
message Alert {