Track the number of buckets dropped.

Test: atest statsd_test
Change-Id: I56973d2c87aaed0f1c4a6908682cc54cda39eceb
This commit is contained in:
Olivier Gaillard
2019-02-06 13:57:24 +00:00
parent 2d0c0e786f
commit 320952bf7d
9 changed files with 20 additions and 0 deletions

View File

@@ -443,6 +443,11 @@ void StatsdStats::noteBadValueType(int metricId) {
getAtomMetricStats(metricId).badValueType++;
}
void StatsdStats::noteBucketDropped(int metricId) {
lock_guard<std::mutex> lock(mLock);
getAtomMetricStats(metricId).bucketDropped++;
}
void StatsdStats::noteConditionChangeInNextBucket(int metricId) {
lock_guard<std::mutex> lock(mLock);
getAtomMetricStats(metricId).conditionChangeInNextBucket++;

View File

@@ -359,6 +359,11 @@ public:
*/
void noteBadValueType(int atomId);
/**
* Buckets were dropped due to reclaim memory.
*/
void noteBucketDropped(int metricId);
/**
* A condition change was too late, arrived in the wrong bucket and was skipped
*/
@@ -414,6 +419,7 @@ public:
long badValueType = 0;
long conditionChangeInNextBucket = 0;
long invalidatedBucket = 0;
long bucketDropped = 0;
} AtomMetricStats;
private:

View File

@@ -243,6 +243,7 @@ void CountMetricProducer::onDumpReportLocked(const int64_t dumpTimeNs,
void CountMetricProducer::dropDataLocked(const int64_t dropTimeNs) {
flushIfNeededLocked(dropTimeNs);
StatsdStats::getInstance().noteBucketDropped(mMetricId);
mPastBuckets.clear();
}

View File

@@ -444,6 +444,7 @@ void DurationMetricProducer::onConditionChangedLocked(const bool conditionMet,
void DurationMetricProducer::dropDataLocked(const int64_t dropTimeNs) {
flushIfNeededLocked(dropTimeNs);
StatsdStats::getInstance().noteBucketDropped(mMetricId);
mPastBuckets.clear();
}

View File

@@ -77,6 +77,7 @@ EventMetricProducer::~EventMetricProducer() {
void EventMetricProducer::dropDataLocked(const int64_t dropTimeNs) {
mProto->clear();
StatsdStats::getInstance().noteBucketDropped(mMetricId);
}
void EventMetricProducer::onSlicedConditionMayChangeLocked(bool overallCondition,

View File

@@ -510,6 +510,7 @@ void GaugeMetricProducer::updateCurrentSlicedBucketForAnomaly() {
void GaugeMetricProducer::dropDataLocked(const int64_t dropTimeNs) {
flushIfNeededLocked(dropTimeNs);
StatsdStats::getInstance().noteBucketDropped(mMetricId);
mPastBuckets.clear();
}

View File

@@ -175,6 +175,7 @@ void ValueMetricProducer::onSlicedConditionMayChangeLocked(bool overallCondition
void ValueMetricProducer::dropDataLocked(const int64_t dropTimeNs) {
flushIfNeededLocked(dropTimeNs);
StatsdStats::getInstance().noteBucketDropped(mMetricId);
mPastBuckets.clear();
}

View File

@@ -418,6 +418,7 @@ message StatsdStatsReport {
optional int64 bad_value_type = 5;
optional int64 condition_change_in_next_bucket = 6;
optional int64 invalidated_bucket = 7;
optional int64 bucket_dropped = 8;
}
repeated AtomMetricStats atom_metric_stats = 17;

View File

@@ -79,6 +79,7 @@ const int FIELD_ID_SKIPPED_FORWARD_BUCKETS = 4;
const int FIELD_ID_BAD_VALUE_TYPE = 5;
const int FIELD_ID_CONDITION_CHANGE_IN_NEXT_BUCKET = 6;
const int FIELD_ID_INVALIDATED_BUCKET = 7;
const int FIELD_ID_BUCKET_DROPPED = 8;
namespace {
@@ -497,6 +498,8 @@ void writeAtomMetricStatsToStream(const std::pair<int, StatsdStats::AtomMetricSt
(long long)pair.second.conditionChangeInNextBucket);
protoOutput->write(FIELD_TYPE_INT64 | FIELD_ID_INVALIDATED_BUCKET,
(long long)pair.second.invalidatedBucket);
protoOutput->write(FIELD_TYPE_INT64 | FIELD_ID_BUCKET_DROPPED,
(long long)pair.second.bucketDropped);
protoOutput->end(token);
}