Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 67cee977 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

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

parents 50a5e71b 50b0c9a6
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -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
+2 −0
Original line number Diff line number Diff line
@@ -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);
+1 −0
Original line number Diff line number Diff line
@@ -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 {