Loading cmds/statsd/src/config/ConfigManager.cpp +10 −10 Original line number Diff line number Diff line Loading @@ -234,7 +234,7 @@ StatsdConfig build_fake_config() { CountMetric* metric = config.add_count_metric(); metric->set_id(1); // METRIC_1 metric->set_what(102); // "SCREEN_TURNED_ON" metric->mutable_bucket()->set_bucket_size_millis(30 * 1000L); metric->set_bucket(ONE_MINUTE); // Anomaly threshold for screen-on count. // TODO(b/70627390): Uncomment once the bug is fixed. Loading @@ -258,7 +258,7 @@ StatsdConfig build_fake_config() { metric = config.add_count_metric(); metric->set_id(2); // "METRIC_2" metric->set_what(104); metric->mutable_bucket()->set_bucket_size_millis(30 * 1000L); metric->set_bucket(ONE_MINUTE); FieldMatcher* dimensions = metric->mutable_dimensions(); dimensions->set_field(UID_PROCESS_STATE_TAG_ID); dimensions->add_child()->set_field(UID_PROCESS_STATE_UID_KEY); Loading @@ -280,7 +280,7 @@ StatsdConfig build_fake_config() { metric = config.add_count_metric(); metric->set_id(3); metric->set_what(104); metric->mutable_bucket()->set_bucket_size_millis(30 * 1000L); metric->set_bucket(ONE_MINUTE); dimensions = metric->mutable_dimensions(); dimensions->set_field(UID_PROCESS_STATE_TAG_ID); Loading @@ -291,7 +291,7 @@ StatsdConfig build_fake_config() { metric = config.add_count_metric(); metric->set_id(4); metric->set_what(107); metric->mutable_bucket()->set_bucket_size_millis(30 * 1000L); metric->set_bucket(ONE_MINUTE); dimensions = metric->mutable_dimensions(); dimensions->set_field(WAKE_LOCK_TAG_ID); dimensions->add_child()->set_field(WAKE_LOCK_UID_KEY_ID); Loading @@ -308,7 +308,7 @@ StatsdConfig build_fake_config() { // Duration of an app holding any wl, while screen on and app in background, slice by uid DurationMetric* durationMetric = config.add_duration_metric(); durationMetric->set_id(5); durationMetric->mutable_bucket()->set_bucket_size_millis(30 * 1000L); durationMetric->set_bucket(ONE_MINUTE); durationMetric->set_aggregation_type(DurationMetric_AggregationType_SUM); dimensions = durationMetric->mutable_dimensions(); dimensions->set_field(WAKE_LOCK_TAG_ID); Loading @@ -325,7 +325,7 @@ StatsdConfig build_fake_config() { // max Duration of an app holding any wl, while screen on and app in background, slice by uid durationMetric = config.add_duration_metric(); durationMetric->set_id(6); durationMetric->mutable_bucket()->set_bucket_size_millis(30 * 1000L); durationMetric->set_bucket(ONE_MINUTE); durationMetric->set_aggregation_type(DurationMetric_AggregationType_MAX_SPARSE); dimensions = durationMetric->mutable_dimensions(); dimensions->set_field(WAKE_LOCK_TAG_ID); Loading @@ -342,7 +342,7 @@ StatsdConfig build_fake_config() { // Duration of an app holding any wl, while screen on and app in background durationMetric = config.add_duration_metric(); durationMetric->set_id(7); durationMetric->mutable_bucket()->set_bucket_size_millis(30 * 1000L); durationMetric->set_bucket(ONE_MINUTE); durationMetric->set_aggregation_type(DurationMetric_AggregationType_MAX_SPARSE); durationMetric->set_what(205); durationMetric->set_condition(204); Loading @@ -357,7 +357,7 @@ StatsdConfig build_fake_config() { // Duration of screen on time. durationMetric = config.add_duration_metric(); durationMetric->set_id(8); durationMetric->mutable_bucket()->set_bucket_size_millis(10 * 1000L); durationMetric->set_bucket(ONE_MINUTE); durationMetric->set_aggregation_type(DurationMetric_AggregationType_SUM); durationMetric->set_what(201); Loading @@ -384,7 +384,7 @@ StatsdConfig build_fake_config() { dimensions->set_field(KERNEL_WAKELOCK_TAG_ID); dimensions->add_child()->set_field(KERNEL_WAKELOCK_NAME_KEY); // This is for testing easier. We should never set bucket size this small. valueMetric->mutable_bucket()->set_bucket_size_millis(60 * 1000L); durationMetric->set_bucket(ONE_MINUTE); // Add an EventMetric to log process state change events. EventMetric* eventMetric = config.add_event_metric(); Loading @@ -398,7 +398,7 @@ StatsdConfig build_fake_config() { auto gaugeFieldMatcher = gaugeMetric->mutable_gauge_fields_filter()->mutable_fields(); gaugeFieldMatcher->set_field(DEVICE_TEMPERATURE_TAG_ID); gaugeFieldMatcher->add_child()->set_field(DEVICE_TEMPERATURE_KEY); gaugeMetric->mutable_bucket()->set_bucket_size_millis(60 * 1000L); durationMetric->set_bucket(ONE_MINUTE); // Event matchers. AtomMatcher* temperatureAtomMatcher = config.add_atom_matcher(); Loading cmds/statsd/src/metrics/CountMetricProducer.cpp +2 −2 Original line number Diff line number Diff line Loading @@ -63,8 +63,8 @@ CountMetricProducer::CountMetricProducer(const ConfigKey& key, const CountMetric const uint64_t startTimeNs) : MetricProducer(metric.id(), key, startTimeNs, conditionIndex, wizard) { // TODO: evaluate initial conditions. and set mConditionMet. if (metric.has_bucket() && metric.bucket().has_bucket_size_millis()) { mBucketSizeNs = metric.bucket().bucket_size_millis() * 1000 * 1000; if (metric.has_bucket()) { mBucketSizeNs = TimeUnitToBucketSizeInMillis(metric.bucket()) * 1000000; } else { mBucketSizeNs = LLONG_MAX; } Loading cmds/statsd/src/metrics/DurationMetricProducer.cpp +2 −2 Original line number Diff line number Diff line Loading @@ -73,8 +73,8 @@ DurationMetricProducer::DurationMetricProducer(const ConfigKey& key, const Durat // TODO: The following boiler plate code appears in all MetricProducers, but we can't abstract // them in the base class, because the proto generated CountMetric, and DurationMetric are // not related. Maybe we should add a template in the future?? if (metric.has_bucket() && metric.bucket().has_bucket_size_millis()) { mBucketSizeNs = metric.bucket().bucket_size_millis() * 1000000; if (metric.has_bucket()) { mBucketSizeNs = TimeUnitToBucketSizeInMillis(metric.bucket()) * 1000000; } else { mBucketSizeNs = LLONG_MAX; } Loading cmds/statsd/src/metrics/GaugeMetricProducer.cpp +6 −5 Original line number Diff line number Diff line Loading @@ -69,11 +69,13 @@ GaugeMetricProducer::GaugeMetricProducer(const ConfigKey& key, const GaugeMetric mAtomTagId(atomTagId) { mCurrentSlicedBucket = std::make_shared<DimToGaugeFieldsMap>(); mCurrentSlicedBucketForAnomaly = std::make_shared<DimToValMap>(); if (metric.has_bucket() && metric.bucket().has_bucket_size_millis()) { mBucketSizeNs = metric.bucket().bucket_size_millis() * 1000 * 1000; int64_t bucketSizeMills = 0; if (metric.has_bucket()) { bucketSizeMills = TimeUnitToBucketSizeInMillis(metric.bucket()); } else { mBucketSizeNs = kDefaultGaugemBucketSizeNs; bucketSizeMills = TimeUnitToBucketSizeInMillis(ONE_HOUR); } mBucketSizeNs = bucketSizeMills * 1000000; mFieldFilter = metric.gauge_fields_filter(); Loading @@ -88,8 +90,7 @@ GaugeMetricProducer::GaugeMetricProducer(const ConfigKey& key, const GaugeMetric // Kicks off the puller immediately. if (mPullTagId != -1) { mStatsPullerManager->RegisterReceiver(mPullTagId, this, metric.bucket().bucket_size_millis()); mStatsPullerManager->RegisterReceiver(mPullTagId, this, bucketSizeMills); } VLOG("metric %lld created. bucket size %lld start_time: %lld", (long long)metric.id(), Loading cmds/statsd/src/metrics/GaugeMetricProducer.h +0 −3 Original line number Diff line number Diff line Loading @@ -86,9 +86,6 @@ private: // Util function to flush the old packet. void flushIfNeededLocked(const uint64_t& eventTime); // The default bucket size for gauge metric is 1 hr. static const uint64_t kDefaultGaugemBucketSizeNs = 60ULL * 60 * 1000 * 1000 * 1000; std::shared_ptr<StatsPullerManager> mStatsPullerManager; // tagId for pulled data. -1 if this is not pulled const int mPullTagId; Loading Loading
cmds/statsd/src/config/ConfigManager.cpp +10 −10 Original line number Diff line number Diff line Loading @@ -234,7 +234,7 @@ StatsdConfig build_fake_config() { CountMetric* metric = config.add_count_metric(); metric->set_id(1); // METRIC_1 metric->set_what(102); // "SCREEN_TURNED_ON" metric->mutable_bucket()->set_bucket_size_millis(30 * 1000L); metric->set_bucket(ONE_MINUTE); // Anomaly threshold for screen-on count. // TODO(b/70627390): Uncomment once the bug is fixed. Loading @@ -258,7 +258,7 @@ StatsdConfig build_fake_config() { metric = config.add_count_metric(); metric->set_id(2); // "METRIC_2" metric->set_what(104); metric->mutable_bucket()->set_bucket_size_millis(30 * 1000L); metric->set_bucket(ONE_MINUTE); FieldMatcher* dimensions = metric->mutable_dimensions(); dimensions->set_field(UID_PROCESS_STATE_TAG_ID); dimensions->add_child()->set_field(UID_PROCESS_STATE_UID_KEY); Loading @@ -280,7 +280,7 @@ StatsdConfig build_fake_config() { metric = config.add_count_metric(); metric->set_id(3); metric->set_what(104); metric->mutable_bucket()->set_bucket_size_millis(30 * 1000L); metric->set_bucket(ONE_MINUTE); dimensions = metric->mutable_dimensions(); dimensions->set_field(UID_PROCESS_STATE_TAG_ID); Loading @@ -291,7 +291,7 @@ StatsdConfig build_fake_config() { metric = config.add_count_metric(); metric->set_id(4); metric->set_what(107); metric->mutable_bucket()->set_bucket_size_millis(30 * 1000L); metric->set_bucket(ONE_MINUTE); dimensions = metric->mutable_dimensions(); dimensions->set_field(WAKE_LOCK_TAG_ID); dimensions->add_child()->set_field(WAKE_LOCK_UID_KEY_ID); Loading @@ -308,7 +308,7 @@ StatsdConfig build_fake_config() { // Duration of an app holding any wl, while screen on and app in background, slice by uid DurationMetric* durationMetric = config.add_duration_metric(); durationMetric->set_id(5); durationMetric->mutable_bucket()->set_bucket_size_millis(30 * 1000L); durationMetric->set_bucket(ONE_MINUTE); durationMetric->set_aggregation_type(DurationMetric_AggregationType_SUM); dimensions = durationMetric->mutable_dimensions(); dimensions->set_field(WAKE_LOCK_TAG_ID); Loading @@ -325,7 +325,7 @@ StatsdConfig build_fake_config() { // max Duration of an app holding any wl, while screen on and app in background, slice by uid durationMetric = config.add_duration_metric(); durationMetric->set_id(6); durationMetric->mutable_bucket()->set_bucket_size_millis(30 * 1000L); durationMetric->set_bucket(ONE_MINUTE); durationMetric->set_aggregation_type(DurationMetric_AggregationType_MAX_SPARSE); dimensions = durationMetric->mutable_dimensions(); dimensions->set_field(WAKE_LOCK_TAG_ID); Loading @@ -342,7 +342,7 @@ StatsdConfig build_fake_config() { // Duration of an app holding any wl, while screen on and app in background durationMetric = config.add_duration_metric(); durationMetric->set_id(7); durationMetric->mutable_bucket()->set_bucket_size_millis(30 * 1000L); durationMetric->set_bucket(ONE_MINUTE); durationMetric->set_aggregation_type(DurationMetric_AggregationType_MAX_SPARSE); durationMetric->set_what(205); durationMetric->set_condition(204); Loading @@ -357,7 +357,7 @@ StatsdConfig build_fake_config() { // Duration of screen on time. durationMetric = config.add_duration_metric(); durationMetric->set_id(8); durationMetric->mutable_bucket()->set_bucket_size_millis(10 * 1000L); durationMetric->set_bucket(ONE_MINUTE); durationMetric->set_aggregation_type(DurationMetric_AggregationType_SUM); durationMetric->set_what(201); Loading @@ -384,7 +384,7 @@ StatsdConfig build_fake_config() { dimensions->set_field(KERNEL_WAKELOCK_TAG_ID); dimensions->add_child()->set_field(KERNEL_WAKELOCK_NAME_KEY); // This is for testing easier. We should never set bucket size this small. valueMetric->mutable_bucket()->set_bucket_size_millis(60 * 1000L); durationMetric->set_bucket(ONE_MINUTE); // Add an EventMetric to log process state change events. EventMetric* eventMetric = config.add_event_metric(); Loading @@ -398,7 +398,7 @@ StatsdConfig build_fake_config() { auto gaugeFieldMatcher = gaugeMetric->mutable_gauge_fields_filter()->mutable_fields(); gaugeFieldMatcher->set_field(DEVICE_TEMPERATURE_TAG_ID); gaugeFieldMatcher->add_child()->set_field(DEVICE_TEMPERATURE_KEY); gaugeMetric->mutable_bucket()->set_bucket_size_millis(60 * 1000L); durationMetric->set_bucket(ONE_MINUTE); // Event matchers. AtomMatcher* temperatureAtomMatcher = config.add_atom_matcher(); Loading
cmds/statsd/src/metrics/CountMetricProducer.cpp +2 −2 Original line number Diff line number Diff line Loading @@ -63,8 +63,8 @@ CountMetricProducer::CountMetricProducer(const ConfigKey& key, const CountMetric const uint64_t startTimeNs) : MetricProducer(metric.id(), key, startTimeNs, conditionIndex, wizard) { // TODO: evaluate initial conditions. and set mConditionMet. if (metric.has_bucket() && metric.bucket().has_bucket_size_millis()) { mBucketSizeNs = metric.bucket().bucket_size_millis() * 1000 * 1000; if (metric.has_bucket()) { mBucketSizeNs = TimeUnitToBucketSizeInMillis(metric.bucket()) * 1000000; } else { mBucketSizeNs = LLONG_MAX; } Loading
cmds/statsd/src/metrics/DurationMetricProducer.cpp +2 −2 Original line number Diff line number Diff line Loading @@ -73,8 +73,8 @@ DurationMetricProducer::DurationMetricProducer(const ConfigKey& key, const Durat // TODO: The following boiler plate code appears in all MetricProducers, but we can't abstract // them in the base class, because the proto generated CountMetric, and DurationMetric are // not related. Maybe we should add a template in the future?? if (metric.has_bucket() && metric.bucket().has_bucket_size_millis()) { mBucketSizeNs = metric.bucket().bucket_size_millis() * 1000000; if (metric.has_bucket()) { mBucketSizeNs = TimeUnitToBucketSizeInMillis(metric.bucket()) * 1000000; } else { mBucketSizeNs = LLONG_MAX; } Loading
cmds/statsd/src/metrics/GaugeMetricProducer.cpp +6 −5 Original line number Diff line number Diff line Loading @@ -69,11 +69,13 @@ GaugeMetricProducer::GaugeMetricProducer(const ConfigKey& key, const GaugeMetric mAtomTagId(atomTagId) { mCurrentSlicedBucket = std::make_shared<DimToGaugeFieldsMap>(); mCurrentSlicedBucketForAnomaly = std::make_shared<DimToValMap>(); if (metric.has_bucket() && metric.bucket().has_bucket_size_millis()) { mBucketSizeNs = metric.bucket().bucket_size_millis() * 1000 * 1000; int64_t bucketSizeMills = 0; if (metric.has_bucket()) { bucketSizeMills = TimeUnitToBucketSizeInMillis(metric.bucket()); } else { mBucketSizeNs = kDefaultGaugemBucketSizeNs; bucketSizeMills = TimeUnitToBucketSizeInMillis(ONE_HOUR); } mBucketSizeNs = bucketSizeMills * 1000000; mFieldFilter = metric.gauge_fields_filter(); Loading @@ -88,8 +90,7 @@ GaugeMetricProducer::GaugeMetricProducer(const ConfigKey& key, const GaugeMetric // Kicks off the puller immediately. if (mPullTagId != -1) { mStatsPullerManager->RegisterReceiver(mPullTagId, this, metric.bucket().bucket_size_millis()); mStatsPullerManager->RegisterReceiver(mPullTagId, this, bucketSizeMills); } VLOG("metric %lld created. bucket size %lld start_time: %lld", (long long)metric.id(), Loading
cmds/statsd/src/metrics/GaugeMetricProducer.h +0 −3 Original line number Diff line number Diff line Loading @@ -86,9 +86,6 @@ private: // Util function to flush the old packet. void flushIfNeededLocked(const uint64_t& eventTime); // The default bucket size for gauge metric is 1 hr. static const uint64_t kDefaultGaugemBucketSizeNs = 60ULL * 60 * 1000 * 1000 * 1000; std::shared_ptr<StatsPullerManager> mStatsPullerManager; // tagId for pulled data. -1 if this is not pulled const int mPullTagId; Loading