summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author android-build-team Robot <android-build-team-robot@google.com> 2018-05-01 00:13:24 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2018-05-01 00:13:24 +0000
commitc0775117c42db38ba3465b04f567d80d5936bf25 (patch)
treef22176fca4f5dc9e719065d81f897927eccae5ae
parenta031ddd6874ccb96a6b4106f294b823a79a443ee (diff)
parenta802d73da625ac72f6a0211aab017f365139112d (diff)
Merge "Clear the past buckets for no-report metrics" into pi-dev
-rw-r--r--cmds/statsd/src/metrics/CountMetricProducer.cpp6
-rw-r--r--cmds/statsd/src/metrics/CountMetricProducer.h2
-rw-r--r--cmds/statsd/src/metrics/DurationMetricProducer.cpp5
-rw-r--r--cmds/statsd/src/metrics/DurationMetricProducer.h2
-rw-r--r--cmds/statsd/src/metrics/EventMetricProducer.cpp4
-rw-r--r--cmds/statsd/src/metrics/EventMetricProducer.h1
-rw-r--r--cmds/statsd/src/metrics/GaugeMetricProducer.cpp6
-rw-r--r--cmds/statsd/src/metrics/GaugeMetricProducer.h1
-rw-r--r--cmds/statsd/src/metrics/MetricProducer.h6
-rw-r--r--cmds/statsd/src/metrics/MetricsManager.cpp2
-rw-r--r--cmds/statsd/src/metrics/ValueMetricProducer.cpp6
-rw-r--r--cmds/statsd/src/metrics/ValueMetricProducer.h1
12 files changed, 42 insertions, 0 deletions
diff --git a/cmds/statsd/src/metrics/CountMetricProducer.cpp b/cmds/statsd/src/metrics/CountMetricProducer.cpp
index e21392cb8ce6..511aec331055 100644
--- a/cmds/statsd/src/metrics/CountMetricProducer.cpp
+++ b/cmds/statsd/src/metrics/CountMetricProducer.cpp
@@ -122,6 +122,12 @@ void CountMetricProducer::onSlicedConditionMayChangeLocked(bool overallCondition
VLOG("Metric %lld onSlicedConditionMayChange", (long long)mMetricId);
}
+
+void CountMetricProducer::clearPastBucketsLocked(const int64_t dumpTimeNs) {
+ flushIfNeededLocked(dumpTimeNs);
+ mPastBuckets.clear();
+}
+
void CountMetricProducer::onDumpReportLocked(const int64_t dumpTimeNs,
const bool include_current_partial_bucket,
ProtoOutputStream* protoOutput) {
diff --git a/cmds/statsd/src/metrics/CountMetricProducer.h b/cmds/statsd/src/metrics/CountMetricProducer.h
index cafc882308d4..8e94a75d9f57 100644
--- a/cmds/statsd/src/metrics/CountMetricProducer.h
+++ b/cmds/statsd/src/metrics/CountMetricProducer.h
@@ -59,6 +59,8 @@ private:
const bool include_current_partial_bucket,
android::util::ProtoOutputStream* protoOutput) override;
+ void clearPastBucketsLocked(const int64_t dumpTimeNs) override;
+
// Internal interface to handle condition change.
void onConditionChangedLocked(const bool conditionMet, const int64_t eventTime) override;
diff --git a/cmds/statsd/src/metrics/DurationMetricProducer.cpp b/cmds/statsd/src/metrics/DurationMetricProducer.cpp
index 3661b31d9ee4..561049249fb7 100644
--- a/cmds/statsd/src/metrics/DurationMetricProducer.cpp
+++ b/cmds/statsd/src/metrics/DurationMetricProducer.cpp
@@ -438,6 +438,11 @@ void DurationMetricProducer::dropDataLocked(const int64_t dropTimeNs) {
mPastBuckets.clear();
}
+void DurationMetricProducer::clearPastBucketsLocked(const int64_t dumpTimeNs) {
+ flushIfNeededLocked(dumpTimeNs);
+ mPastBuckets.clear();
+}
+
void DurationMetricProducer::onDumpReportLocked(const int64_t dumpTimeNs,
const bool include_current_partial_bucket,
ProtoOutputStream* protoOutput) {
diff --git a/cmds/statsd/src/metrics/DurationMetricProducer.h b/cmds/statsd/src/metrics/DurationMetricProducer.h
index 80fbdde2df09..f755294cd1c3 100644
--- a/cmds/statsd/src/metrics/DurationMetricProducer.h
+++ b/cmds/statsd/src/metrics/DurationMetricProducer.h
@@ -65,6 +65,8 @@ private:
const bool include_current_partial_bucket,
android::util::ProtoOutputStream* protoOutput) override;
+ void clearPastBucketsLocked(const int64_t dumpTimeNs) override;
+
// Internal interface to handle condition change.
void onConditionChangedLocked(const bool conditionMet, const int64_t eventTime) override;
diff --git a/cmds/statsd/src/metrics/EventMetricProducer.cpp b/cmds/statsd/src/metrics/EventMetricProducer.cpp
index 2f2679efab65..23f780adb01e 100644
--- a/cmds/statsd/src/metrics/EventMetricProducer.cpp
+++ b/cmds/statsd/src/metrics/EventMetricProducer.cpp
@@ -100,6 +100,10 @@ std::unique_ptr<std::vector<uint8_t>> serializeProtoLocked(ProtoOutputStream& pr
return buffer;
}
+void EventMetricProducer::clearPastBucketsLocked(const int64_t dumpTimeNs) {
+ mProto->clear();
+}
+
void EventMetricProducer::onDumpReportLocked(const int64_t dumpTimeNs,
const bool include_current_partial_bucket,
ProtoOutputStream* protoOutput) {
diff --git a/cmds/statsd/src/metrics/EventMetricProducer.h b/cmds/statsd/src/metrics/EventMetricProducer.h
index 5c2917400b10..23302c4063b8 100644
--- a/cmds/statsd/src/metrics/EventMetricProducer.h
+++ b/cmds/statsd/src/metrics/EventMetricProducer.h
@@ -49,6 +49,7 @@ private:
void onDumpReportLocked(const int64_t dumpTimeNs,
const bool include_current_partial_bucket,
android::util::ProtoOutputStream* protoOutput) override;
+ void clearPastBucketsLocked(const int64_t dumpTimeNs) override;
// Internal interface to handle condition change.
void onConditionChangedLocked(const bool conditionMet, const int64_t eventTime) override;
diff --git a/cmds/statsd/src/metrics/GaugeMetricProducer.cpp b/cmds/statsd/src/metrics/GaugeMetricProducer.cpp
index 12708567043b..005cb7117d6b 100644
--- a/cmds/statsd/src/metrics/GaugeMetricProducer.cpp
+++ b/cmds/statsd/src/metrics/GaugeMetricProducer.cpp
@@ -160,6 +160,12 @@ void GaugeMetricProducer::dumpStatesLocked(FILE* out, bool verbose) const {
}
}
+void GaugeMetricProducer::clearPastBucketsLocked(const int64_t dumpTimeNs) {
+ flushIfNeededLocked(dumpTimeNs);
+ mPastBuckets.clear();
+ mSkippedBuckets.clear();
+}
+
void GaugeMetricProducer::onDumpReportLocked(const int64_t dumpTimeNs,
const bool include_current_partial_bucket,
ProtoOutputStream* protoOutput) {
diff --git a/cmds/statsd/src/metrics/GaugeMetricProducer.h b/cmds/statsd/src/metrics/GaugeMetricProducer.h
index 71d5912df6ae..8af2f3632e02 100644
--- a/cmds/statsd/src/metrics/GaugeMetricProducer.h
+++ b/cmds/statsd/src/metrics/GaugeMetricProducer.h
@@ -91,6 +91,7 @@ private:
void onDumpReportLocked(const int64_t dumpTimeNs,
const bool include_current_partial_bucket,
android::util::ProtoOutputStream* protoOutput) override;
+ void clearPastBucketsLocked(const int64_t dumpTimeNs) override;
// for testing
GaugeMetricProducer(const ConfigKey& key, const GaugeMetric& gaugeMetric,
diff --git a/cmds/statsd/src/metrics/MetricProducer.h b/cmds/statsd/src/metrics/MetricProducer.h
index 532ecbf36d72..42396490b3d3 100644
--- a/cmds/statsd/src/metrics/MetricProducer.h
+++ b/cmds/statsd/src/metrics/MetricProducer.h
@@ -119,6 +119,11 @@ public:
return onDumpReportLocked(dumpTimeNs, include_current_partial_bucket, protoOutput);
}
+ void clearPastBuckets(const int64_t dumpTimeNs) {
+ std::lock_guard<std::mutex> lock(mMutex);
+ return clearPastBucketsLocked(dumpTimeNs);
+ }
+
void dumpStates(FILE* out, bool verbose) const {
std::lock_guard<std::mutex> lock(mMutex);
dumpStatesLocked(out, verbose);
@@ -177,6 +182,7 @@ protected:
virtual void onDumpReportLocked(const int64_t dumpTimeNs,
const bool include_current_partial_bucket,
android::util::ProtoOutputStream* protoOutput) = 0;
+ virtual void clearPastBucketsLocked(const int64_t dumpTimeNs) = 0;
virtual size_t byteSizeLocked() const = 0;
virtual void dumpStatesLocked(FILE* out, bool verbose) const = 0;
diff --git a/cmds/statsd/src/metrics/MetricsManager.cpp b/cmds/statsd/src/metrics/MetricsManager.cpp
index 47a1a86f861f..0d3aebfd46a5 100644
--- a/cmds/statsd/src/metrics/MetricsManager.cpp
+++ b/cmds/statsd/src/metrics/MetricsManager.cpp
@@ -201,6 +201,8 @@ void MetricsManager::onDumpReport(const int64_t dumpTimeStampNs,
protoOutput->start(FIELD_TYPE_MESSAGE | FIELD_COUNT_REPEATED | FIELD_ID_METRICS);
producer->onDumpReport(dumpTimeStampNs, include_current_partial_bucket, protoOutput);
protoOutput->end(token);
+ } else {
+ producer->clearPastBuckets(dumpTimeStampNs);
}
}
for (const auto& annotation : mAnnotations) {
diff --git a/cmds/statsd/src/metrics/ValueMetricProducer.cpp b/cmds/statsd/src/metrics/ValueMetricProducer.cpp
index 27fd78f4ed94..506cf383e036 100644
--- a/cmds/statsd/src/metrics/ValueMetricProducer.cpp
+++ b/cmds/statsd/src/metrics/ValueMetricProducer.cpp
@@ -151,6 +151,12 @@ void ValueMetricProducer::dropDataLocked(const int64_t dropTimeNs) {
mPastBuckets.clear();
}
+void ValueMetricProducer::clearPastBucketsLocked(const int64_t dumpTimeNs) {
+ flushIfNeededLocked(dumpTimeNs);
+ mPastBuckets.clear();
+ mSkippedBuckets.clear();
+}
+
void ValueMetricProducer::onDumpReportLocked(const int64_t dumpTimeNs,
const bool include_current_partial_bucket,
ProtoOutputStream* protoOutput) {
diff --git a/cmds/statsd/src/metrics/ValueMetricProducer.h b/cmds/statsd/src/metrics/ValueMetricProducer.h
index 8df30d3de284..64604c2f674f 100644
--- a/cmds/statsd/src/metrics/ValueMetricProducer.h
+++ b/cmds/statsd/src/metrics/ValueMetricProducer.h
@@ -89,6 +89,7 @@ private:
void onDumpReportLocked(const int64_t dumpTimeNs,
const bool include_current_partial_bucket,
android::util::ProtoOutputStream* protoOutput) override;
+ void clearPastBucketsLocked(const int64_t dumpTimeNs) override;
// Internal interface to handle condition change.
void onConditionChangedLocked(const bool conditionMet, const int64_t eventTime) override;