diff options
| author | 2018-04-11 13:55:04 -0700 | |
|---|---|---|
| committer | 2018-05-09 23:14:26 +0000 | |
| commit | b2532daf4d9922b706054705b8dbf94a9df6a191 (patch) | |
| tree | 2a2f4e30358e63847a4405dec478412ee5168717 | |
| parent | 689866352b2e36fb10128244c19a671b4bc1fdc5 (diff) | |
Fix the gauge metric data size estimation.
Test: statsd test
BUG: b/77906846
Change-Id: Ie5ab54771acadde1e825289fe5ec491cc2225458
| -rw-r--r-- | cmds/statsd/src/metrics/GaugeMetricProducer.cpp | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/cmds/statsd/src/metrics/GaugeMetricProducer.cpp b/cmds/statsd/src/metrics/GaugeMetricProducer.cpp index a940d58b7c4d..21a1567775ed 100644 --- a/cmds/statsd/src/metrics/GaugeMetricProducer.cpp +++ b/cmds/statsd/src/metrics/GaugeMetricProducer.cpp @@ -186,7 +186,6 @@ void GaugeMetricProducer::onDumpReportLocked(const int64_t dumpTimeNs, flushIfNeededLocked(dumpTimeNs); } - flushIfNeededLocked(dumpTimeNs); if (mPastBuckets.empty()) { return; } @@ -538,7 +537,14 @@ void GaugeMetricProducer::flushCurrentBucketLocked(const int64_t& eventTimeNs) { 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; } |