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

Commit f248c0d4 authored by Olivier Gaillard's avatar Olivier Gaillard
Browse files

Tracks the total number of buckets.

To be able to normalize the other counters, e.g. % of invalid buckets.

Test: atest statsd_test
Change-Id: I7bef93f3acfa133baf3618ce0ffee919d23a1ad3
parent f9aa3044
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -493,6 +493,11 @@ void StatsdStats::noteInvalidatedBucket(int64_t metricId) {
    getAtomMetricStats(metricId).invalidatedBucket++;
}

void StatsdStats::noteBucketCount(int64_t metricId) {
    lock_guard<std::mutex> lock(mLock);
    getAtomMetricStats(metricId).bucketCount++;
}

void StatsdStats::noteBucketBoundaryDelayNs(int64_t metricId, int64_t timeDelayNs) {
    lock_guard<std::mutex> lock(mLock);
    AtomMetricStats& pullStats = getAtomMetricStats(metricId);
+6 −0
Original line number Diff line number Diff line
@@ -402,6 +402,11 @@ public:
     */
    void noteInvalidatedBucket(int64_t metricId);

    /**
     * Tracks the total number of buckets (include skipped/invalid buckets).
     */
    void noteBucketCount(int64_t metricId);

    /**
     * For pulls at bucket boundaries, it represents the misalignment between the real timestamp and
     * the end of the bucket.
@@ -464,6 +469,7 @@ public:
        int64_t minBucketBoundaryDelayNs = 0;
        int64_t maxBucketBoundaryDelayNs = 0;
        long bucketUnknownCondition = 0;
        long bucketCount = 0;
    } AtomMetricStats;

private:
+1 −0
Original line number Diff line number Diff line
@@ -371,6 +371,7 @@ void CountMetricProducer::flushCurrentBucketLocked(const int64_t& eventTimeNs,
        }
    }

    StatsdStats::getInstance().noteBucketCount(mMetricId);
    // Only resets the counters, but doesn't setup the times nor numbers.
    // (Do not clear since the old one is still referenced in mAnomalyTrackers).
    mCurrentSlicedCounter = std::make_shared<DimToValMap>();
+1 −0
Original line number Diff line number Diff line
@@ -601,6 +601,7 @@ void DurationMetricProducer::flushCurrentBucketLocked(const int64_t& eventTimeNs
            whatIt++;
        }
    }
    StatsdStats::getInstance().noteBucketCount(mMetricId);
}

void DurationMetricProducer::dumpStatesLocked(FILE* out, bool verbose) const {
+1 −0
Original line number Diff line number Diff line
@@ -576,6 +576,7 @@ void GaugeMetricProducer::flushCurrentBucketLocked(const int64_t& eventTimeNs,
        }
    }

    StatsdStats::getInstance().noteBucketCount(mMetricId);
    mCurrentSlicedBucket = std::make_shared<DimToGaugeAtomsMap>();
}

Loading