diff options
| author | 2018-03-14 16:45:49 +0000 | |
|---|---|---|
| committer | 2018-03-14 16:45:49 +0000 | |
| commit | dc8e7fa0ae99a3b8f67519de090a119dbda9b622 (patch) | |
| tree | fc743fd8ecf2b751b7176c7b9dbfbe9b628b0cc6 | |
| parent | d854d917ecf7826ab5a48c62d0d8496c0b399d6e (diff) | |
| parent | a78d00874d4e274937734a1b73aef4b6389eb3cd (diff) | |
Merge "Dump the stats for count/gauge/value metrics." into pi-dev
| -rw-r--r-- | cmds/statsd/src/metrics/CountMetricProducer.cpp | 18 | ||||
| -rw-r--r-- | cmds/statsd/src/metrics/CountMetricProducer.h | 2 | ||||
| -rw-r--r-- | cmds/statsd/src/metrics/GaugeMetricProducer.cpp | 18 | ||||
| -rw-r--r-- | cmds/statsd/src/metrics/GaugeMetricProducer.h | 2 | ||||
| -rw-r--r-- | cmds/statsd/src/metrics/ValueMetricProducer.cpp | 17 | ||||
| -rw-r--r-- | cmds/statsd/src/metrics/ValueMetricProducer.h | 2 |
6 files changed, 56 insertions, 3 deletions
diff --git a/cmds/statsd/src/metrics/CountMetricProducer.cpp b/cmds/statsd/src/metrics/CountMetricProducer.cpp index 22b2a30af328..2b187b2709df 100644 --- a/cmds/statsd/src/metrics/CountMetricProducer.cpp +++ b/cmds/statsd/src/metrics/CountMetricProducer.cpp @@ -99,6 +99,24 @@ CountMetricProducer::~CountMetricProducer() { VLOG("~CountMetricProducer() called"); } +void CountMetricProducer::dumpStatesLocked(FILE* out, bool verbose) const { + if (mCurrentSlicedCounter == nullptr || + mCurrentSlicedCounter->size() == 0) { + return; + } + + fprintf(out, "CountMetric %lld dimension size %lu\n", (long long)mMetricId, + (unsigned long)mCurrentSlicedCounter->size()); + if (verbose) { + for (const auto& it : *mCurrentSlicedCounter) { + fprintf(out, "\t(what)%s\t(condition)%s %lld\n", + it.first.getDimensionKeyInWhat().toString().c_str(), + it.first.getDimensionKeyInCondition().toString().c_str(), + (unsigned long long)it.second); + } + } +} + void CountMetricProducer::onSlicedConditionMayChangeLocked(const uint64_t eventTime) { VLOG("Metric %lld onSlicedConditionMayChange", (long long)mMetricId); } diff --git a/cmds/statsd/src/metrics/CountMetricProducer.h b/cmds/statsd/src/metrics/CountMetricProducer.h index 1d8e42be635c..d9f2c4c8f40d 100644 --- a/cmds/statsd/src/metrics/CountMetricProducer.h +++ b/cmds/statsd/src/metrics/CountMetricProducer.h @@ -67,7 +67,7 @@ private: // Internal function to calculate the current used bytes. size_t byteSizeLocked() const override; - void dumpStatesLocked(FILE* out, bool verbose) const override{}; + void dumpStatesLocked(FILE* out, bool verbose) const override; void dropDataLocked(const uint64_t dropTimeNs) override; diff --git a/cmds/statsd/src/metrics/GaugeMetricProducer.cpp b/cmds/statsd/src/metrics/GaugeMetricProducer.cpp index e479e5caec2f..a8f80d97d0d3 100644 --- a/cmds/statsd/src/metrics/GaugeMetricProducer.cpp +++ b/cmds/statsd/src/metrics/GaugeMetricProducer.cpp @@ -126,6 +126,24 @@ GaugeMetricProducer::~GaugeMetricProducer() { } } +void GaugeMetricProducer::dumpStatesLocked(FILE* out, bool verbose) const { + if (mCurrentSlicedBucket == nullptr || + mCurrentSlicedBucket->size() == 0) { + return; + } + + fprintf(out, "GaugeMetric %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 %d atoms\n", + it.first.getDimensionKeyInWhat().toString().c_str(), + it.first.getDimensionKeyInCondition().toString().c_str(), + (int)it.second.size()); + } + } +} + void GaugeMetricProducer::onDumpReportLocked(const uint64_t dumpTimeNs, ProtoOutputStream* protoOutput) { VLOG("gauge metric %lld report now...", (long long)mMetricId); diff --git a/cmds/statsd/src/metrics/GaugeMetricProducer.h b/cmds/statsd/src/metrics/GaugeMetricProducer.h index ca8dc7582680..b9e67de6897c 100644 --- a/cmds/statsd/src/metrics/GaugeMetricProducer.h +++ b/cmds/statsd/src/metrics/GaugeMetricProducer.h @@ -106,7 +106,7 @@ private: // Internal function to calculate the current used bytes. size_t byteSizeLocked() const override; - void dumpStatesLocked(FILE* out, bool verbose) const override{}; + void dumpStatesLocked(FILE* out, bool verbose) const override; void dropDataLocked(const uint64_t dropTimeNs) override; diff --git a/cmds/statsd/src/metrics/ValueMetricProducer.cpp b/cmds/statsd/src/metrics/ValueMetricProducer.cpp index 09913dc513fd..079aea5dcc60 100644 --- a/cmds/statsd/src/metrics/ValueMetricProducer.cpp +++ b/cmds/statsd/src/metrics/ValueMetricProducer.cpp @@ -243,6 +243,23 @@ void ValueMetricProducer::onDataPulled(const std::vector<std::shared_ptr<LogEven } } +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 diff --git a/cmds/statsd/src/metrics/ValueMetricProducer.h b/cmds/statsd/src/metrics/ValueMetricProducer.h index 5e42bd255df4..cc2309b1784b 100644 --- a/cmds/statsd/src/metrics/ValueMetricProducer.h +++ b/cmds/statsd/src/metrics/ValueMetricProducer.h @@ -99,7 +99,7 @@ private: // Internal function to calculate the current used bytes. size_t byteSizeLocked() const override; - void dumpStatesLocked(FILE* out, bool verbose) const override{}; + void dumpStatesLocked(FILE* out, bool verbose) const override; // Util function to flush the old packet. void flushIfNeededLocked(const uint64_t& eventTime) override; |