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

Commit 06dba5d7 authored by Yao Chen's avatar Yao Chen
Browse files

Add API to let metrics directly drop data without writing to an output.

+ Metrics will do flushIfNeeded() to correctly move the clock and informing
  AnomalyTracker the past bucket info, and then clear past buckets.

+ We will still keep the current bucket data for the validity of the future metrics.

Bug: 70571383
Test: statsd_test
Change-Id: Ib13c45574974e7b4e82bd8f305091dc93bda76f5
parent aec69501
Loading
Loading
Loading
Loading
+1 −3
Original line number Diff line number Diff line
@@ -330,9 +330,7 @@ void StatsLogProcessor::flushIfNecessaryLocked(
    mLastByteSizeTimes[key] = timestampNs;
    if (totalBytes >
        StatsdStats::kMaxMetricsBytesPerConfig) {  // Too late. We need to start clearing data.
        // TODO(b/70571383): By 12/15/2017 add API to drop data directly
        ProtoOutputStream proto;
        metricsManager.onDumpReport(timestampNs, &proto);
        metricsManager.dropData(timestampNs);
        StatsdStats::getInstance().noteDataDropped(key);
        VLOG("StatsD had to toss out metrics for %s", key.ToString().c_str());
    } else if (totalBytes > .9 * StatsdStats::kMaxMetricsBytesPerConfig) {
+0 −1
Original line number Diff line number Diff line
@@ -113,7 +113,6 @@ private:
    FRIEND_TEST(StatsLogProcessorTest, TestRateLimitByteSize);
    FRIEND_TEST(StatsLogProcessorTest, TestRateLimitBroadcast);
    FRIEND_TEST(StatsLogProcessorTest, TestDropWhenByteSizeTooLarge);
    FRIEND_TEST(StatsLogProcessorTest, TestDropWhenByteSizeTooLarge);
    FRIEND_TEST(WakelockDurationE2eTest, TestAggregatedPredicateDimensionsForSumDuration1);
    FRIEND_TEST(WakelockDurationE2eTest, TestAggregatedPredicateDimensionsForSumDuration2);
    FRIEND_TEST(WakelockDurationE2eTest, TestAggregatedPredicateDimensionsForSumDuration3);
+4 −1
Original line number Diff line number Diff line
@@ -151,8 +151,11 @@ void CountMetricProducer::onDumpReportLocked(const uint64_t dumpTimeNs,
    protoOutput->end(protoToken);

    mPastBuckets.clear();
}

    // TODO: Clear mDimensionKeyMap once the report is dumped.
void CountMetricProducer::dropDataLocked(const uint64_t dropTimeNs) {
    flushIfNeededLocked(dropTimeNs);
    mPastBuckets.clear();
}

void CountMetricProducer::onConditionChangedLocked(const bool conditionMet,
+2 −0
Original line number Diff line number Diff line
@@ -69,6 +69,8 @@ private:

    void dumpStatesLocked(FILE* out, bool verbose) const override{};

    void dropDataLocked(const uint64_t dropTimeNs) override;

    // Util function to flush the old packet.
    void flushIfNeededLocked(const uint64_t& newEventTime) override;

+5 −0
Original line number Diff line number Diff line
@@ -221,6 +221,11 @@ void DurationMetricProducer::onConditionChangedLocked(const bool conditionMet,
    }
}

void DurationMetricProducer::dropDataLocked(const uint64_t dropTimeNs) {
    flushIfNeededLocked(dropTimeNs);
    mPastBuckets.clear();
}

void DurationMetricProducer::onDumpReportLocked(const uint64_t dumpTimeNs,
                                                ProtoOutputStream* protoOutput) {
    flushIfNeededLocked(dumpTimeNs);
Loading