diff options
Diffstat (limited to 'cmds/statsd/src/metrics/CountMetricProducer.cpp')
-rw-r--r-- | cmds/statsd/src/metrics/CountMetricProducer.cpp | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/cmds/statsd/src/metrics/CountMetricProducer.cpp b/cmds/statsd/src/metrics/CountMetricProducer.cpp index 43f53e057000..5ca88142f152 100644 --- a/cmds/statsd/src/metrics/CountMetricProducer.cpp +++ b/cmds/statsd/src/metrics/CountMetricProducer.cpp @@ -66,9 +66,8 @@ const int FIELD_ID_END_BUCKET_ELAPSED_MILLIS = 6; CountMetricProducer::CountMetricProducer(const ConfigKey& key, const CountMetric& metric, const int conditionIndex, const sp<ConditionWizard>& wizard, - const int64_t startTimeNs) - : MetricProducer(metric.id(), key, startTimeNs, conditionIndex, wizard) { - // TODO: evaluate initial conditions. and set mConditionMet. + const int64_t timeBaseNs, const int64_t startTimeNs) + : MetricProducer(metric.id(), key, timeBaseNs, conditionIndex, wizard) { if (metric.has_bucket()) { mBucketSizeNs = TimeUnitToBucketSizeInMillisGuardrailed(key.GetUid(), metric.bucket()) * 1000000; @@ -101,6 +100,10 @@ CountMetricProducer::CountMetricProducer(const ConfigKey& key, const CountMetric mConditionSliced = (metric.links().size() > 0) || (mDimensionsInCondition.size() > 0); + flushIfNeededLocked(startTimeNs); + // Adjust start for partial bucket + mCurrentBucketStartTimeNs = startTimeNs; + VLOG("metric %lld created. bucket size %lld start_time: %lld", (long long)metric.id(), (long long)mBucketSizeNs, (long long)mTimeBaseNs); } @@ -140,6 +143,7 @@ void CountMetricProducer::clearPastBucketsLocked(const int64_t dumpTimeNs) { void CountMetricProducer::onDumpReportLocked(const int64_t dumpTimeNs, const bool include_current_partial_bucket, + const bool erase_data, std::set<string> *str_set, ProtoOutputStream* protoOutput) { if (include_current_partial_bucket) { @@ -227,7 +231,9 @@ void CountMetricProducer::onDumpReportLocked(const int64_t dumpTimeNs, protoOutput->end(protoToken); - mPastBuckets.clear(); + if (erase_data) { + mPastBuckets.clear(); + } } void CountMetricProducer::dropDataLocked(const int64_t dropTimeNs) { |