Dump the stats for count/gauge/value metrics.
Bug: b/74159560 Test: statsd test Change-Id: I1410309ecfdfc2a5becf8d0c620c68a621ebc5fa
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user