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

Commit 5088e72c authored by tsaichristine's avatar tsaichristine
Browse files

Populate initial base info with unknown state values

Set the current state key to a HashableDimensionKey with -1
(kStateUnknown) for each sliced state atom. Previously, the current
state key was being set to the DEFAULT_DIMENSION_KEY which is an empty
HashableDimensionKey.

Bug: 155487198
Test: make statsd_test && adb sync data && adb shell
data/nativetest/statsd_test/statsd_test

Change-Id: Icaa187ecae599407695d86eec6104d210aa98714
parent 12416fba
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -293,6 +293,17 @@ void MetricProducer::mapStateValue(const int32_t atomId, FieldValue* value) {
    }
}

HashableDimensionKey MetricProducer::getUnknownStateKey() {
    HashableDimensionKey stateKey;
    for (auto atom : mSlicedStateAtoms) {
        FieldValue fieldValue;
        fieldValue.mField.setTag(atom);
        fieldValue.mValue.setInt(StateTracker::kStateUnknown);
        stateKey.addValue(fieldValue);
    }
    return stateKey;
}

DropEvent MetricProducer::buildDropEvent(const int64_t dropTimeNs, const BucketDropReason reason) {
    DropEvent event;
    event.reason = reason;
+4 −0
Original line number Diff line number Diff line
@@ -384,6 +384,10 @@ protected:
    // If no state map exists, keep the original state value.
    void mapStateValue(const int32_t atomId, FieldValue* value);

    // Returns a HashableDimensionKey with unknown state value for each state
    // atom.
    HashableDimensionKey getUnknownStateKey();

    DropEvent buildDropEvent(const int64_t dropTimeNs, const BucketDropReason reason);

    // Returns true if the number of drop events in the current bucket has
+6 −4
Original line number Diff line number Diff line
@@ -767,22 +767,24 @@ void ValueMetricProducer::onMatchedLogEventInternalLocked(
    bool shouldSkipForPulledMetric = mIsPulled && !mUseDiff
            && mCondition != ConditionState::kTrue;
    if (shouldSkipForPushMetric || shouldSkipForPulledMetric) {
        VLOG("ValueMetric skip event because condition is false");
        VLOG("ValueMetric skip event because condition is false and we are not using diff (for "
             "pulled metric)");
        return;
    }

    if (hitGuardRailLocked(eventKey)) {
        return;
    }

    vector<BaseInfo>& baseInfos = mCurrentBaseInfo[whatKey];
    if (baseInfos.size() < mFieldMatchers.size()) {
        VLOG("Resizing number of intervals to %d", (int)mFieldMatchers.size());
        baseInfos.resize(mFieldMatchers.size());
    }

    for (auto baseInfo : baseInfos) {
    for (BaseInfo& baseInfo : baseInfos) {
        if (!baseInfo.hasCurrentState) {
            baseInfo.currentState = DEFAULT_DIMENSION_KEY;
            baseInfo.currentState = getUnknownStateKey();
            baseInfo.hasCurrentState = true;
        }
    }
@@ -1033,7 +1035,7 @@ void ValueMetricProducer::initCurrentSlicedBucket(int64_t nextBucketStartTimeNs)
        } else {
            it++;
        }
        // TODO: remove mCurrentBaseInfo entries when obsolete
        // TODO(b/157655103): remove mCurrentBaseInfo entries when obsolete
    }

    mCurrentBucketIsInvalid = false;
+291 −80

File changed.

Preview size limit exceeded, changes collapsed.