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

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

Tracks unknown condition states.

When statsd starts or is killed, the conditions are not initialized.
Tracks how many buckets are skipped because the condition was unknown.

This change does not change the behavior of statsd. In the future, we
might want to invalid buckets with a condition that has been partially
unknown.

Bug: 124100912
Test: atest statsd_test
Change-Id: Ie3d2eb5e30c21dda3203ad30f9b486961ff570cf
parent 1e0d8fcc
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -448,6 +448,11 @@ void StatsdStats::noteBucketDropped(int64_t metricId) {
    getAtomMetricStats(metricId).bucketDropped++;
}

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

void StatsdStats::noteConditionChangeInNextBucket(int64_t metricId) {
    lock_guard<std::mutex> lock(mLock);
    getAtomMetricStats(metricId).conditionChangeInNextBucket++;
+6 −0
Original line number Diff line number Diff line
@@ -380,6 +380,11 @@ public:
     */
    void noteBucketBoundaryDelayNs(int64_t metricId, int64_t timeDelayNs);

    /**
     * Number of buckets with unknown condition.
     */
    void noteBucketUnknownCondition(int64_t metricId);

    /**
     * Reset the historical stats. Including all stats in icebox, and the tracked stats about
     * metrics, matchers, and atoms. The active configs will be kept and StatsdStats will continue
@@ -428,6 +433,7 @@ public:
        long bucketDropped = 0;
        int64_t minBucketBoundaryDelayNs = 0;
        int64_t maxBucketBoundaryDelayNs = 0;
        long bucketUnknownCondition = 0;
    } AtomMetricStats;

private:
+1 −1
Original line number Diff line number Diff line
@@ -250,7 +250,7 @@ void CountMetricProducer::dropDataLocked(const int64_t dropTimeNs) {
void CountMetricProducer::onConditionChangedLocked(const bool conditionMet,
                                                   const int64_t eventTime) {
    VLOG("Metric %lld onConditionChanged", (long long)mMetricId);
    mCondition = conditionMet;
    mCondition = conditionMet ? ConditionState::kTrue : ConditionState::kFalse;
}

bool CountMetricProducer::hitGuardRailLocked(const MetricDimensionKey& newKey) {
+4 −3
Original line number Diff line number Diff line
@@ -433,7 +433,7 @@ void DurationMetricProducer::onSlicedConditionMayChangeLocked(bool overallCondit
void DurationMetricProducer::onConditionChangedLocked(const bool conditionMet,
                                                      const int64_t eventTime) {
    VLOG("Metric %lld onConditionChanged", (long long)mMetricId);
    mCondition = conditionMet;
    mCondition = conditionMet ? ConditionState::kTrue : ConditionState::kFalse;
    flushIfNeededLocked(eventTime);
    for (auto& whatIt : mCurrentSlicedDurationTrackerMap) {
        for (auto& pair : whatIt.second) {
@@ -767,12 +767,13 @@ void DurationMetricProducer::onMatchedLogEventLocked(const size_t matcherIndex,
                           !mSameConditionDimensionsInTracker,
                           !mHasLinksToAllConditionDimensionsInTracker,
                           &dimensionKeysInCondition);
        condition = (conditionState == ConditionState::kTrue);
        condition = conditionState == ConditionState::kTrue;
        if (mDimensionsInCondition.empty() && condition) {
            dimensionKeysInCondition.insert(DEFAULT_DIMENSION_KEY);
        }
    } else {
        condition = mCondition;
        // TODO: The unknown condition state is not handled here, we should fix it.
        condition = mCondition == ConditionState::kTrue;
        if (condition) {
            dimensionKeysInCondition.insert(DEFAULT_DIMENSION_KEY);
        }
+1 −0
Original line number Diff line number Diff line
@@ -137,6 +137,7 @@ private:

    FRIEND_TEST(DurationMetricTrackerTest, TestNoCondition);
    FRIEND_TEST(DurationMetricTrackerTest, TestNonSlicedCondition);
    FRIEND_TEST(DurationMetricTrackerTest, TestNonSlicedConditionUnknownState);
    FRIEND_TEST(DurationMetricTrackerTest, TestSumDurationWithUpgrade);
    FRIEND_TEST(DurationMetricTrackerTest, TestSumDurationWithUpgradeInFollowingBucket);
    FRIEND_TEST(DurationMetricTrackerTest, TestMaxDurationWithUpgrade);
Loading