Dump the stats for count/gauge/value metrics.
Bug: b/74159560
Test: statsd test
Change-Id: I1410309ecfdfc2a5becf8d0c620c68a621ebc5fa
diff --git a/cmds/statsd/src/metrics/ValueMetricProducer.cpp b/cmds/statsd/src/metrics/ValueMetricProducer.cpp
index 09913dc..079aea5 100644
--- a/cmds/statsd/src/metrics/ValueMetricProducer.cpp
+++ b/cmds/statsd/src/metrics/ValueMetricProducer.cpp
@@ -243,6 +243,23 @@
}
}
+void ValueMetricProducer::dumpStatesLocked(FILE* out, bool verbose) const {
+ if (mCurrentSlicedBucket.size() == 0) {
+ return;
+ }
+
+ fprintf(out, "ValueMetric %lld dimension size %lu\n", (long long)mMetricId,
+ (unsigned long)mCurrentSlicedBucket.size());
+ if (verbose) {
+ for (const auto& it : mCurrentSlicedBucket) {
+ fprintf(out, "\t(what)%s\t(condition)%s (value)%lld\n",
+ it.first.getDimensionKeyInWhat().toString().c_str(),
+ it.first.getDimensionKeyInCondition().toString().c_str(),
+ (unsigned long long)it.second.sum);
+ }
+ }
+}
+
bool ValueMetricProducer::hitGuardRailLocked(const MetricDimensionKey& newKey) {
// ===========GuardRail==============
// 1. Report the tuple count if the tuple count > soft limit