Merge "Guardrail the max gauge atoms per dimension in one bucket." into pi-dev

am: 67cee97754

Change-Id: I74ad62e53fc245f8c77741db3235543846f70832
This commit is contained in:
Yangster-mac
2018-05-11 20:15:13 -07:00
committed by android-build-merger
3 changed files with 8 additions and 1 deletions

View File

@@ -84,7 +84,8 @@ GaugeMetricProducer::GaugeMetricProducer(const ConfigKey& key, const GaugeMetric
mDimensionHardLimit(StatsdStats::kAtomDimensionKeySizeLimitMap.find(pullTagId) !=
StatsdStats::kAtomDimensionKeySizeLimitMap.end()
? StatsdStats::kAtomDimensionKeySizeLimitMap.at(pullTagId).second
: StatsdStats::kDimensionKeySizeHardLimit) {
: StatsdStats::kDimensionKeySizeHardLimit),
mGaugeAtomsPerDimensionLimit(metric.max_num_gauge_atoms_per_bucket()) {
mCurrentSlicedBucket = std::make_shared<DimToGaugeAtomsMap>();
mCurrentSlicedBucketForAnomaly = std::make_shared<DimToValMap>();
int64_t bucketSizeMills = 0;
@@ -433,6 +434,9 @@ void GaugeMetricProducer::onMatchedLogEventInternalLocked(
if (hitGuardRailLocked(eventKey)) {
return;
}
if ((*mCurrentSlicedBucket)[eventKey].size() >= mGaugeAtomsPerDimensionLimit) {
return;
}
GaugeAtom gaugeAtom(getGaugeFields(event), eventTimeNs, getWallClockNs());
(*mCurrentSlicedBucket)[eventKey].push_back(gaugeAtom);
// Anomaly detection on gauge metric only works when there is one numeric

View File

@@ -164,6 +164,8 @@ private:
const size_t mDimensionHardLimit;
const size_t mGaugeAtomsPerDimensionLimit;
FRIEND_TEST(GaugeMetricProducerTest, TestWithCondition);
FRIEND_TEST(GaugeMetricProducerTest, TestWithSlicedCondition);
FRIEND_TEST(GaugeMetricProducerTest, TestNoCondition);

View File

@@ -239,6 +239,7 @@ message GaugeMetric {
optional SamplingType sampling_type = 9 [default = RANDOM_ONE_SAMPLE] ;
optional int64 min_bucket_size_nanos = 10;
optional int64 max_num_gauge_atoms_per_bucket = 11 [default = 10];
}
message ValueMetric {