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

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

Merge "Some fixes in duration metrics"

parents 985cdcb8 d59a6589
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -117,11 +117,11 @@ unique_ptr<DurationTracker> DurationMetricProducer::createDurationTracker(
        case DurationMetric_AggregationType_SUM:
            return make_unique<OringDurationTracker>(
                    mConfigKey, mMetricId, eventKey, mWizard, mConditionTrackerIndex, mNested,
                    mCurrentBucketStartTimeNs, mBucketSizeNs, mAnomalyTrackers);
                    mCurrentBucketStartTimeNs, mBucketSizeNs, mConditionSliced, mAnomalyTrackers);
        case DurationMetric_AggregationType_MAX_SPARSE:
            return make_unique<MaxDurationTracker>(
                    mConfigKey, mMetricId, eventKey, mWizard, mConditionTrackerIndex, mNested,
                    mCurrentBucketStartTimeNs, mBucketSizeNs, mAnomalyTrackers);
                    mCurrentBucketStartTimeNs, mBucketSizeNs, mConditionSliced, mAnomalyTrackers);
    }
}

+4 −1
Original line number Diff line number Diff line
@@ -62,7 +62,7 @@ class DurationTracker {
public:
    DurationTracker(const ConfigKey& key, const int64_t& id, const HashableDimensionKey& eventKey,
                    sp<ConditionWizard> wizard, int conditionIndex, bool nesting,
                    uint64_t currentBucketStartNs, uint64_t bucketSizeNs,
                    uint64_t currentBucketStartNs, uint64_t bucketSizeNs, bool conditionSliced,
                    const std::vector<sp<DurationAnomalyTracker>>& anomalyTrackers)
        : mConfigKey(key),
          mTrackerId(id),
@@ -74,6 +74,7 @@ public:
          mCurrentBucketStartTimeNs(currentBucketStartNs),
          mDuration(0),
          mCurrentBucketNum(0),
          mConditionSliced(conditionSliced),
          mAnomalyTrackers(anomalyTrackers){};

    virtual ~DurationTracker(){};
@@ -163,6 +164,8 @@ protected:

    uint64_t mCurrentBucketNum;

    const bool mConditionSliced;

    std::vector<sp<DurationAnomalyTracker>> mAnomalyTrackers;

    FRIEND_TEST(OringDurationTrackerTest, TestPredictAnomalyTimestamp);
+5 −2
Original line number Diff line number Diff line
@@ -28,9 +28,10 @@ MaxDurationTracker::MaxDurationTracker(const ConfigKey& key, const int64_t& id,
                                       const HashableDimensionKey& eventKey,
                                       sp<ConditionWizard> wizard, int conditionIndex, bool nesting,
                                       uint64_t currentBucketStartNs, uint64_t bucketSizeNs,
                                       bool conditionSliced,
                                       const vector<sp<DurationAnomalyTracker>>& anomalyTrackers)
    : DurationTracker(key, id, eventKey, wizard, conditionIndex, nesting, currentBucketStartNs,
                      bucketSizeNs, anomalyTrackers) {
                      bucketSizeNs, conditionSliced, anomalyTrackers) {
}

bool MaxDurationTracker::hitGuardRail(const HashableDimensionKey& newKey) {
@@ -63,7 +64,9 @@ void MaxDurationTracker::noteStart(const HashableDimensionKey& key, bool conditi
    }

    DurationInfo& duration = mInfos[key];
    if (mConditionSliced) {
        duration.conditionKeys = conditionKey;
    }
    VLOG("MaxDuration: key %s start condition %d", key.c_str(), condition);

    switch (duration.state) {
+1 −1
Original line number Diff line number Diff line
@@ -31,7 +31,7 @@ public:
    MaxDurationTracker(const ConfigKey& key, const int64_t& id,
                       const HashableDimensionKey& eventKey, sp<ConditionWizard> wizard,
                       int conditionIndex, bool nesting, uint64_t currentBucketStartNs,
                       uint64_t bucketSizeNs,
                       uint64_t bucketSizeNs, bool conditionSliced,
                       const std::vector<sp<DurationAnomalyTracker>>& anomalyTrackers);
    void noteStart(const HashableDimensionKey& key, bool condition, const uint64_t eventTime,
                   const ConditionKey& conditionKey) override;
+4 −4
Original line number Diff line number Diff line
@@ -27,10 +27,10 @@ using std::pair;
OringDurationTracker::OringDurationTracker(
        const ConfigKey& key, const int64_t& id, const HashableDimensionKey& eventKey,
        sp<ConditionWizard> wizard, int conditionIndex, bool nesting, uint64_t currentBucketStartNs,
        uint64_t bucketSizeNs, const vector<sp<DurationAnomalyTracker>>& anomalyTrackers)

        uint64_t bucketSizeNs, bool conditionSliced,
        const vector<sp<DurationAnomalyTracker>>& anomalyTrackers)
    : DurationTracker(key, id, eventKey, wizard, conditionIndex, nesting, currentBucketStartNs,
                      bucketSizeNs, anomalyTrackers),
                      bucketSizeNs, conditionSliced, anomalyTrackers),
      mStarted(),
      mPaused() {
    mLastStartTime = 0;
@@ -73,7 +73,7 @@ void OringDurationTracker::noteStart(const HashableDimensionKey& key, bool condi
        mPaused[key]++;
    }

    if (mConditionKeyMap.find(key) == mConditionKeyMap.end()) {
    if (mConditionSliced && mConditionKeyMap.find(key) == mConditionKeyMap.end()) {
        mConditionKeyMap[key] = conditionKey;
    }

Loading