Merge "Fix the gauge metric data size estimation." into pi-dev
am: 3b592910c5
Change-Id: Ie8977d334e3345dd273f7f7fb587e5cd0edd77d8
diff --git a/cmds/statsd/src/metrics/GaugeMetricProducer.cpp b/cmds/statsd/src/metrics/GaugeMetricProducer.cpp
index 06d8bcd..55dde10 100644
--- a/cmds/statsd/src/metrics/GaugeMetricProducer.cpp
+++ b/cmds/statsd/src/metrics/GaugeMetricProducer.cpp
@@ -186,7 +186,6 @@
flushIfNeededLocked(dumpTimeNs);
}
- flushIfNeededLocked(dumpTimeNs);
if (mPastBuckets.empty()) {
return;
}
@@ -542,7 +541,14 @@
size_t GaugeMetricProducer::byteSizeLocked() const {
size_t totalSize = 0;
for (const auto& pair : mPastBuckets) {
- totalSize += pair.second.size() * kBucketSize;
+ for (const auto& bucket : pair.second) {
+ totalSize += bucket.mGaugeAtoms.size() * sizeof(GaugeAtom);
+ for (const auto& atom : bucket.mGaugeAtoms) {
+ if (atom.mFields != nullptr) {
+ totalSize += atom.mFields->size() * sizeof(FieldValue);
+ }
+ }
+ }
}
return totalSize;
}