diff options
| author | 2018-01-04 22:53:29 +0000 | |
|---|---|---|
| committer | 2018-01-04 22:53:29 +0000 | |
| commit | efc331b287e8e227ec4aca7459f04a951f5b81c3 (patch) | |
| tree | 6f1b20707986d4bdf9a88660d5c4aef23d04d95a | |
| parent | 5d8307186f589d764de34ed9f4a5456a1de6a35d (diff) | |
| parent | b814481ad1f8d0e429d799b1571a6272e1a7f6c5 (diff) | |
Merge "Use TimeUnit enum to specify the bucket size."
24 files changed, 159 insertions, 108 deletions
diff --git a/cmds/statsd/src/config/ConfigManager.cpp b/cmds/statsd/src/config/ConfigManager.cpp index c41301aecb98..6c1c3d3bc38e 100644 --- a/cmds/statsd/src/config/ConfigManager.cpp +++ b/cmds/statsd/src/config/ConfigManager.cpp @@ -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. @@ -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); @@ -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); @@ -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); @@ -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); @@ -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); @@ -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); @@ -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); @@ -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(); @@ -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(); diff --git a/cmds/statsd/src/metrics/CountMetricProducer.cpp b/cmds/statsd/src/metrics/CountMetricProducer.cpp index a24364df0fb2..3e98098ad62a 100644 --- a/cmds/statsd/src/metrics/CountMetricProducer.cpp +++ b/cmds/statsd/src/metrics/CountMetricProducer.cpp @@ -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; } diff --git a/cmds/statsd/src/metrics/DurationMetricProducer.cpp b/cmds/statsd/src/metrics/DurationMetricProducer.cpp index 0117b6d7faa5..3f8a8ffef26a 100644 --- a/cmds/statsd/src/metrics/DurationMetricProducer.cpp +++ b/cmds/statsd/src/metrics/DurationMetricProducer.cpp @@ -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; } diff --git a/cmds/statsd/src/metrics/GaugeMetricProducer.cpp b/cmds/statsd/src/metrics/GaugeMetricProducer.cpp index eaf1de238e8d..64ac6fa4c99d 100644 --- a/cmds/statsd/src/metrics/GaugeMetricProducer.cpp +++ b/cmds/statsd/src/metrics/GaugeMetricProducer.cpp @@ -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(); @@ -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(), diff --git a/cmds/statsd/src/metrics/GaugeMetricProducer.h b/cmds/statsd/src/metrics/GaugeMetricProducer.h index 2a6401d6dcac..fdf8e61a4277 100644 --- a/cmds/statsd/src/metrics/GaugeMetricProducer.h +++ b/cmds/statsd/src/metrics/GaugeMetricProducer.h @@ -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; diff --git a/cmds/statsd/src/metrics/ValueMetricProducer.cpp b/cmds/statsd/src/metrics/ValueMetricProducer.cpp index 5f7d76140397..74bd6f97d535 100644 --- a/cmds/statsd/src/metrics/ValueMetricProducer.cpp +++ b/cmds/statsd/src/metrics/ValueMetricProducer.cpp @@ -61,8 +61,6 @@ const int FIELD_ID_START_BUCKET_NANOS = 1; const int FIELD_ID_END_BUCKET_NANOS = 2; const int FIELD_ID_VALUE = 3; -static const uint64_t kDefaultBucketSizeMillis = 60 * 60 * 1000L; - // ValueMetric has a minimum bucket size of 10min so that we don't pull too frequently ValueMetricProducer::ValueMetricProducer(const ConfigKey& key, const ValueMetric& metric, const int conditionIndex, @@ -74,12 +72,14 @@ ValueMetricProducer::ValueMetricProducer(const ConfigKey& key, const ValueMetric mStatsPullerManager(statsPullerManager), mPullTagId(pullTagId) { // TODO: valuemetric for pushed events may need unlimited bucket length - 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 = kDefaultBucketSizeMillis * 1000 * 1000; + bucketSizeMills = TimeUnitToBucketSizeInMillis(ONE_HOUR); } + mBucketSizeNs = bucketSizeMills * 1000000; mDimensions = metric.dimensions(); if (metric.links().size() > 0) { @@ -90,8 +90,7 @@ ValueMetricProducer::ValueMetricProducer(const ConfigKey& key, const ValueMetric if (!metric.has_condition() && mPullTagId != -1) { VLOG("Setting up periodic pulling for %d", mPullTagId); - mStatsPullerManager->RegisterReceiver(mPullTagId, this, - metric.bucket().bucket_size_millis()); + mStatsPullerManager->RegisterReceiver(mPullTagId, this, bucketSizeMills); } VLOG("value metric %lld created. bucket size %lld start_time: %lld", (long long)metric.id(), (long long)mBucketSizeNs, (long long)mStartTimeNs); diff --git a/cmds/statsd/src/stats_log_util.cpp b/cmds/statsd/src/stats_log_util.cpp index 476e11724318..b335b580183c 100644 --- a/cmds/statsd/src/stats_log_util.cpp +++ b/cmds/statsd/src/stats_log_util.cpp @@ -218,8 +218,34 @@ void writeFieldValueTreeToStream(const FieldValueMap &fieldValueMap, protoOutput->end(tokenStack.top().first); tokenStack.pop(); } +} - +int64_t TimeUnitToBucketSizeInMillis(TimeUnit unit) { + switch (unit) { + case ONE_MINUTE: + return 60 * 1000LL; + case FIVE_MINUTES: + return 5 * 60 * 1000LL; + case TEN_MINUTES: + return 10 * 60 * 1000LL; + case THIRTY_MINUTES: + return 30 * 60 * 1000LL; + case ONE_HOUR: + return 60 * 60 * 1000LL; + case THREE_HOURS: + return 3 * 60 * 60 * 1000LL; + case SIX_HOURS: + return 6 * 60 * 60 * 1000LL; + case TWELVE_HOURS: + return 12 * 60 * 60 * 1000LL; + case ONE_DAY: + return 24 * 60 * 60 * 1000LL; + case CTS: + return 1000; + case TIME_UNIT_UNSPECIFIED: + default: + return -1; + } } } // namespace statsd diff --git a/cmds/statsd/src/stats_log_util.h b/cmds/statsd/src/stats_log_util.h index 1f8186083d12..33303dc951ad 100644 --- a/cmds/statsd/src/stats_log_util.h +++ b/cmds/statsd/src/stats_log_util.h @@ -17,6 +17,7 @@ #pragma once #include <android/util/ProtoOutputStream.h> +#include "frameworks/base/cmds/statsd/src/statsd_config.pb.h" #include "frameworks/base/cmds/statsd/src/stats_log.pb.h" #include "field_util.h" @@ -36,6 +37,9 @@ void writeFieldProtoToStream( void writeFieldValueTreeToStream(const FieldValueMap &fieldValueMap, util::ProtoOutputStream* protoOutput); +// Convert the TimeUnit enum to the bucket size in millis. +int64_t TimeUnitToBucketSizeInMillis(TimeUnit unit); + } // namespace statsd } // namespace os } // namespace android
\ No newline at end of file diff --git a/cmds/statsd/src/statsd_config.proto b/cmds/statsd/src/statsd_config.proto index 1e0a437f30c2..d45a6b038ccb 100644 --- a/cmds/statsd/src/statsd_config.proto +++ b/cmds/statsd/src/statsd_config.proto @@ -29,6 +29,20 @@ enum Position { ANY = 3; } +enum TimeUnit { + TIME_UNIT_UNSPECIFIED = 0; + ONE_MINUTE = 1; + FIVE_MINUTES = 2; + TEN_MINUTES = 3; + THIRTY_MINUTES = 4; + ONE_HOUR = 5; + THREE_HOURS = 6; + SIX_HOURS = 7; + TWELVE_HOURS = 8; + ONE_DAY = 9; + CTS = 1000; +} + message FieldMatcher { optional int32 field = 1; @@ -166,7 +180,7 @@ message CountMetric { optional FieldMatcher dimensions = 4; - optional Bucket bucket = 5; + optional TimeUnit bucket = 5; repeated MetricConditionLink links = 6; } @@ -189,7 +203,7 @@ message DurationMetric { optional FieldMatcher dimensions = 6; - optional Bucket bucket = 7; + optional TimeUnit bucket = 7; } message GaugeMetric { @@ -203,7 +217,7 @@ message GaugeMetric { optional FieldMatcher dimensions = 5; - optional Bucket bucket = 6; + optional TimeUnit bucket = 6; repeated MetricConditionLink links = 7; } @@ -219,7 +233,7 @@ message ValueMetric { optional FieldMatcher dimensions = 5; - optional Bucket bucket = 6; + optional TimeUnit bucket = 6; repeated MetricConditionLink links = 7; diff --git a/cmds/statsd/tests/MetricsManager_test.cpp b/cmds/statsd/tests/MetricsManager_test.cpp index cb212a76a1dd..fe0f59d30c81 100644 --- a/cmds/statsd/tests/MetricsManager_test.cpp +++ b/cmds/statsd/tests/MetricsManager_test.cpp @@ -80,7 +80,7 @@ StatsdConfig buildGoodConfig() { CountMetric* metric = config.add_count_metric(); metric->set_id(3); metric->set_what(StringToId("SCREEN_IS_ON")); - metric->mutable_bucket()->set_bucket_size_millis(30 * 1000L); + metric->set_bucket(ONE_MINUTE); metric->mutable_dimensions()->set_field(2 /*SCREEN_STATE_CHANGE*/); metric->mutable_dimensions()->add_child()->set_field(1); @@ -131,7 +131,7 @@ StatsdConfig buildAlertWithUnknownMetric() { CountMetric* metric = config.add_count_metric(); metric->set_id(3); metric->set_what(StringToId("SCREEN_IS_ON")); - metric->mutable_bucket()->set_bucket_size_millis(30 * 1000L); + metric->set_bucket(ONE_MINUTE); metric->mutable_dimensions()->set_field(2 /*SCREEN_STATE_CHANGE*/); metric->mutable_dimensions()->add_child()->set_field(1); @@ -177,7 +177,7 @@ StatsdConfig buildMissingPredicate() { CountMetric* metric = config.add_count_metric(); metric->set_id(3); metric->set_what(StringToId("SCREEN_EVENT")); - metric->mutable_bucket()->set_bucket_size_millis(30 * 1000L); + metric->set_bucket(ONE_MINUTE); metric->set_condition(StringToId("SOME_CONDITION")); AtomMatcher* eventMatcher = config.add_atom_matcher(); @@ -215,7 +215,7 @@ StatsdConfig buildDimensionMetricsWithMultiTags() { CountMetric* metric = config.add_count_metric(); metric->set_id(3); metric->set_what(StringToId("BATTERY_LOW")); - metric->mutable_bucket()->set_bucket_size_millis(30 * 1000L); + metric->set_bucket(ONE_MINUTE); // This case is interesting. We want to dimension across two atoms. metric->mutable_dimensions()->add_child()->set_field(1); diff --git a/cmds/statsd/tests/e2e/MetricConditionLink_e2e_test.cpp b/cmds/statsd/tests/e2e/MetricConditionLink_e2e_test.cpp index b56b8176cceb..cbcc36b78785 100644 --- a/cmds/statsd/tests/e2e/MetricConditionLink_e2e_test.cpp +++ b/cmds/statsd/tests/e2e/MetricConditionLink_e2e_test.cpp @@ -15,6 +15,7 @@ #include <gtest/gtest.h> #include "src/StatsLogProcessor.h" +#include "src/stats_log_util.h" #include "tests/statsd_test_util.h" #include <vector> @@ -68,7 +69,7 @@ StatsdConfig CreateStatsdConfig() { // The metric is dimensioning by uid only. *countMetric->mutable_dimensions() = CreateDimensions(android::util::PROCESS_LIFE_CYCLE_STATE_CHANGED, {1}); - countMetric->mutable_bucket()->set_bucket_size_millis(30 * 1000LL); + countMetric->set_bucket(ONE_MINUTE); // Links between crash atom and condition of app is in syncing. auto links = countMetric->add_links(); @@ -95,7 +96,8 @@ StatsdConfig CreateStatsdConfig() { TEST(MetricConditionLinkE2eTest, TestMultiplePredicatesAndLinks) { auto config = CreateStatsdConfig(); uint64_t bucketStartTimeNs = 10000000000; - uint64_t bucketSizeNs = config.count_metric(0).bucket().bucket_size_millis() * 1000 * 1000; + uint64_t bucketSizeNs = + TimeUnitToBucketSizeInMillis(config.count_metric(0).bucket()) * 1000000LL; ConfigKey cfgKey; auto processor = CreateStatsLogProcessor(bucketStartTimeNs / NS_PER_SEC, config, cfgKey); diff --git a/cmds/statsd/tests/e2e/WakelockDuration_e2e_test.cpp b/cmds/statsd/tests/e2e/WakelockDuration_e2e_test.cpp index ecdb002c1863..47e8a72a615c 100644 --- a/cmds/statsd/tests/e2e/WakelockDuration_e2e_test.cpp +++ b/cmds/statsd/tests/e2e/WakelockDuration_e2e_test.cpp @@ -15,6 +15,7 @@ #include <gtest/gtest.h> #include "src/StatsLogProcessor.h" +#include "src/stats_log_util.h" #include "tests/statsd_test_util.h" #include <vector> @@ -51,7 +52,7 @@ StatsdConfig CreateStatsdConfig(DurationMetric::AggregationType aggregationType) *durationMetric->mutable_dimensions() = CreateAttributionUidDimensions( android::util::WAKELOCK_STATE_CHANGED, {Position::FIRST}); - durationMetric->mutable_bucket()->set_bucket_size_millis(30 * 1000LL); + durationMetric->set_bucket(ONE_MINUTE); return config; } @@ -61,7 +62,7 @@ TEST(WakelockDurationE2eTest, TestAggregatedPredicateDimensions) { auto config = CreateStatsdConfig(aggregationType); uint64_t bucketStartTimeNs = 10000000000; uint64_t bucketSizeNs = - config.duration_metric(0).bucket().bucket_size_millis() * 1000 * 1000; + TimeUnitToBucketSizeInMillis(config.duration_metric(0).bucket()) * 1000000LL; auto processor = CreateStatsLogProcessor(bucketStartTimeNs / NS_PER_SEC, config, cfgKey); EXPECT_EQ(processor->mMetricsManagers.size(), 1u); diff --git a/cmds/statsd/tests/metrics/CountMetricProducer_test.cpp b/cmds/statsd/tests/metrics/CountMetricProducer_test.cpp index 4cb242aa3bcc..768336b08416 100644 --- a/cmds/statsd/tests/metrics/CountMetricProducer_test.cpp +++ b/cmds/statsd/tests/metrics/CountMetricProducer_test.cpp @@ -14,6 +14,7 @@ #include "src/metrics/CountMetricProducer.h" #include "src/dimension.h" +#include "src/stats_log_util.h" #include "metrics_test_helper.h" #include "tests/statsd_test_util.h" @@ -38,14 +39,14 @@ const ConfigKey kConfigKey(0, 12345); TEST(CountMetricProducerTest, TestNonDimensionalEvents) { int64_t bucketStartTimeNs = 10000000000; - int64_t bucketSizeNs = 30 * 1000 * 1000 * 1000LL; + int64_t bucketSizeNs = TimeUnitToBucketSizeInMillis(ONE_MINUTE) * 1000000LL; int64_t bucket2StartTimeNs = bucketStartTimeNs + bucketSizeNs; int64_t bucket3StartTimeNs = bucketStartTimeNs + 2 * bucketSizeNs; int tagId = 1; CountMetric metric; metric.set_id(1); - metric.mutable_bucket()->set_bucket_size_millis(bucketSizeNs / 1000000); + metric.set_bucket(ONE_MINUTE); LogEvent event1(tagId, bucketStartTimeNs + 1); LogEvent event2(tagId, bucketStartTimeNs + 2); @@ -98,11 +99,11 @@ TEST(CountMetricProducerTest, TestNonDimensionalEvents) { TEST(CountMetricProducerTest, TestEventsWithNonSlicedCondition) { int64_t bucketStartTimeNs = 10000000000; - int64_t bucketSizeNs = 30 * 1000 * 1000 * 1000LL; + int64_t bucketSizeNs = TimeUnitToBucketSizeInMillis(ONE_MINUTE) * 1000000LL; CountMetric metric; metric.set_id(1); - metric.mutable_bucket()->set_bucket_size_millis(bucketSizeNs / 1000000); + metric.set_bucket(ONE_MINUTE); metric.set_condition(StringToId("SCREEN_ON")); LogEvent event1(1, bucketStartTimeNs + 1); @@ -137,14 +138,14 @@ TEST(CountMetricProducerTest, TestEventsWithNonSlicedCondition) { TEST(CountMetricProducerTest, TestEventsWithSlicedCondition) { int64_t bucketStartTimeNs = 10000000000; - int64_t bucketSizeNs = 30 * 1000 * 1000 * 1000LL; + int64_t bucketSizeNs = TimeUnitToBucketSizeInMillis(ONE_MINUTE) * 1000000LL; int tagId = 1; int conditionTagId = 2; CountMetric metric; metric.set_id(1); - metric.mutable_bucket()->set_bucket_size_millis(bucketSizeNs / 1000000); + metric.set_bucket(ONE_MINUTE); metric.set_condition(StringToId("APP_IN_BACKGROUND_PER_UID_AND_SCREEN_ON")); MetricConditionLink* link = metric.add_links(); link->set_condition(StringToId("APP_IN_BACKGROUND_PER_UID")); @@ -199,13 +200,13 @@ TEST(CountMetricProducerTest, TestAnomalyDetection) { alert.set_refractory_period_secs(1); int64_t bucketStartTimeNs = 10000000000; - int64_t bucketSizeNs = 30 * NS_PER_SEC; + int64_t bucketSizeNs = TimeUnitToBucketSizeInMillis(ONE_MINUTE) * 1000000LL; int64_t bucket2StartTimeNs = bucketStartTimeNs + bucketSizeNs; int64_t bucket3StartTimeNs = bucketStartTimeNs + 2 * bucketSizeNs; CountMetric metric; metric.set_id(1); - metric.mutable_bucket()->set_bucket_size_millis(bucketSizeNs / 1000000); + metric.set_bucket(ONE_MINUTE); sp<MockConditionWizard> wizard = new NaggyMock<MockConditionWizard>(); CountMetricProducer countProducer(kConfigKey, metric, -1 /*-1 meaning no condition*/, wizard, diff --git a/cmds/statsd/tests/metrics/DurationMetricProducer_test.cpp b/cmds/statsd/tests/metrics/DurationMetricProducer_test.cpp index a4213dec7c44..a59f1fe66354 100644 --- a/cmds/statsd/tests/metrics/DurationMetricProducer_test.cpp +++ b/cmds/statsd/tests/metrics/DurationMetricProducer_test.cpp @@ -13,6 +13,7 @@ // limitations under the License. #include "src/metrics/DurationMetricProducer.h" +#include "src/stats_log_util.h" #include "metrics_test_helper.h" #include "src/condition/ConditionWizard.h" @@ -41,11 +42,11 @@ const ConfigKey kConfigKey(0, 12345); TEST(DurationMetricTrackerTest, TestNoCondition) { sp<MockConditionWizard> wizard = new NaggyMock<MockConditionWizard>(); uint64_t bucketStartTimeNs = 10000000000; - uint64_t bucketSizeNs = 30 * 1000 * 1000 * 1000LL; + int64_t bucketSizeNs = TimeUnitToBucketSizeInMillis(ONE_MINUTE) * 1000000LL; DurationMetric metric; metric.set_id(1); - metric.mutable_bucket()->set_bucket_size_millis(bucketSizeNs / 1000000); + metric.set_bucket(ONE_MINUTE); metric.set_aggregation_type(DurationMetric_AggregationType_SUM); int tagId = 1; @@ -76,11 +77,11 @@ TEST(DurationMetricTrackerTest, TestNoCondition) { TEST(DurationMetricTrackerTest, TestNonSlicedCondition) { sp<MockConditionWizard> wizard = new NaggyMock<MockConditionWizard>(); uint64_t bucketStartTimeNs = 10000000000; - uint64_t bucketSizeNs = 30 * 1000 * 1000 * 1000LL; + int64_t bucketSizeNs = TimeUnitToBucketSizeInMillis(ONE_MINUTE) * 1000000LL; DurationMetric metric; metric.set_id(1); - metric.mutable_bucket()->set_bucket_size_millis(bucketSizeNs / 1000000); + metric.set_bucket(ONE_MINUTE); metric.set_aggregation_type(DurationMetric_AggregationType_SUM); int tagId = 1; diff --git a/cmds/statsd/tests/metrics/GaugeMetricProducer_test.cpp b/cmds/statsd/tests/metrics/GaugeMetricProducer_test.cpp index 749cf26e4630..7f67c91e0edb 100644 --- a/cmds/statsd/tests/metrics/GaugeMetricProducer_test.cpp +++ b/cmds/statsd/tests/metrics/GaugeMetricProducer_test.cpp @@ -13,6 +13,7 @@ // limitations under the License. #include "src/metrics/GaugeMetricProducer.h" +#include "src/stats_log_util.h" #include "logd/LogEvent.h" #include "metrics_test_helper.h" #include "tests/statsd_test_util.h" @@ -39,7 +40,7 @@ const ConfigKey kConfigKey(0, 12345); const int tagId = 1; const int64_t metricId = 123; const int64_t bucketStartTimeNs = 10000000000; -const int64_t bucketSizeNs = 60 * 1000 * 1000 * 1000LL; +const int64_t bucketSizeNs = TimeUnitToBucketSizeInMillis(ONE_MINUTE) * 1000000LL; const int64_t bucket2StartTimeNs = bucketStartTimeNs + bucketSizeNs; const int64_t bucket3StartTimeNs = bucketStartTimeNs + 2 * bucketSizeNs; const int64_t bucket4StartTimeNs = bucketStartTimeNs + 3 * bucketSizeNs; @@ -47,7 +48,7 @@ const int64_t bucket4StartTimeNs = bucketStartTimeNs + 3 * bucketSizeNs; TEST(GaugeMetricProducerTest, TestNoCondition) { GaugeMetric metric; metric.set_id(metricId); - metric.mutable_bucket()->set_bucket_size_millis(bucketSizeNs / 1000000); + metric.set_bucket(ONE_MINUTE); metric.mutable_gauge_fields_filter()->set_include_all(false); auto gaugeFieldMatcher = metric.mutable_gauge_fields_filter()->mutable_fields(); gaugeFieldMatcher->set_field(tagId); @@ -121,7 +122,7 @@ TEST(GaugeMetricProducerTest, TestNoCondition) { TEST(GaugeMetricProducerTest, TestWithCondition) { GaugeMetric metric; metric.set_id(metricId); - metric.mutable_bucket()->set_bucket_size_millis(bucketSizeNs / 1000000); + metric.set_bucket(ONE_MINUTE); auto gaugeFieldMatcher = metric.mutable_gauge_fields_filter()->mutable_fields(); gaugeFieldMatcher->set_field(tagId); gaugeFieldMatcher->add_child()->set_field(2); @@ -188,7 +189,7 @@ TEST(GaugeMetricProducerTest, TestAnomalyDetection) { GaugeMetric metric; metric.set_id(metricId); - metric.mutable_bucket()->set_bucket_size_millis(bucketSizeNs / 1000000); + metric.set_bucket(ONE_MINUTE); auto gaugeFieldMatcher = metric.mutable_gauge_fields_filter()->mutable_fields(); gaugeFieldMatcher->set_field(tagId); gaugeFieldMatcher->add_child()->set_field(2); diff --git a/cmds/statsd/tests/metrics/ValueMetricProducer_test.cpp b/cmds/statsd/tests/metrics/ValueMetricProducer_test.cpp index 15acca4bd2a1..459da0170fc1 100644 --- a/cmds/statsd/tests/metrics/ValueMetricProducer_test.cpp +++ b/cmds/statsd/tests/metrics/ValueMetricProducer_test.cpp @@ -13,6 +13,7 @@ // limitations under the License. #include "src/metrics/ValueMetricProducer.h" +#include "src/stats_log_util.h" #include "metrics_test_helper.h" #include "tests/statsd_test_util.h" @@ -39,7 +40,7 @@ const ConfigKey kConfigKey(0, 12345); const int tagId = 1; const int64_t metricId = 123; const int64_t bucketStartTimeNs = 10000000000; -const int64_t bucketSizeNs = 60 * 1000 * 1000 * 1000LL; +const int64_t bucketSizeNs = TimeUnitToBucketSizeInMillis(ONE_MINUTE) * 1000000LL; const int64_t bucket2StartTimeNs = bucketStartTimeNs + bucketSizeNs; const int64_t bucket3StartTimeNs = bucketStartTimeNs + 2 * bucketSizeNs; const int64_t bucket4StartTimeNs = bucketStartTimeNs + 3 * bucketSizeNs; @@ -50,7 +51,7 @@ const int64_t bucket4StartTimeNs = bucketStartTimeNs + 3 * bucketSizeNs; TEST(ValueMetricProducerTest, TestNonDimensionalEvents) { ValueMetric metric; metric.set_id(metricId); - metric.mutable_bucket()->set_bucket_size_millis(bucketSizeNs / 1000000); + metric.set_bucket(ONE_MINUTE); metric.mutable_value_field()->set_field(tagId); metric.mutable_value_field()->add_child()->set_field(2); @@ -127,7 +128,7 @@ TEST(ValueMetricProducerTest, TestNonDimensionalEvents) { TEST(ValueMetricProducerTest, TestEventsWithNonSlicedCondition) { ValueMetric metric; metric.set_id(metricId); - metric.mutable_bucket()->set_bucket_size_millis(bucketSizeNs / 1000000); + metric.set_bucket(ONE_MINUTE); metric.mutable_value_field()->set_field(tagId); metric.mutable_value_field()->add_child()->set_field(2); metric.set_condition(StringToId("SCREEN_ON")); @@ -204,7 +205,7 @@ TEST(ValueMetricProducerTest, TestEventsWithNonSlicedCondition) { TEST(ValueMetricProducerTest, TestPushedEventsWithoutCondition) { ValueMetric metric; metric.set_id(metricId); - metric.mutable_bucket()->set_bucket_size_millis(bucketSizeNs / 1000000); + metric.set_bucket(ONE_MINUTE); metric.mutable_value_field()->set_field(tagId); metric.mutable_value_field()->add_child()->set_field(2); @@ -252,7 +253,7 @@ TEST(ValueMetricProducerTest, TestAnomalyDetection) { ValueMetric metric; metric.set_id(metricId); - metric.mutable_bucket()->set_bucket_size_millis(bucketSizeNs / 1000000); + metric.set_bucket(ONE_MINUTE); metric.mutable_value_field()->set_field(tagId); metric.mutable_value_field()->add_child()->set_field(2); diff --git a/cmds/statsd/tools/loadtest/src/com/android/statsd/loadtest/BatteryDataRecorder.java b/cmds/statsd/tools/loadtest/src/com/android/statsd/loadtest/BatteryDataRecorder.java index d2ff892680a7..709b28b298e0 100644 --- a/cmds/statsd/tools/loadtest/src/com/android/statsd/loadtest/BatteryDataRecorder.java +++ b/cmds/statsd/tools/loadtest/src/com/android/statsd/loadtest/BatteryDataRecorder.java @@ -18,6 +18,7 @@ package com.android.statsd.loadtest; import android.annotation.Nullable; import android.content.Context; import android.util.Log; +import com.android.internal.os.StatsdConfigProto.TimeUnit; import java.text.ParseException; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -26,9 +27,9 @@ public class BatteryDataRecorder extends PerfDataRecorder { private static final String TAG = "loadtest.BatteryDataRecorder"; private static final String DUMP_FILENAME = TAG + "_dump.tmp"; - public BatteryDataRecorder(boolean placebo, int replication, long bucketMins, long periodSecs, + public BatteryDataRecorder(boolean placebo, int replication, TimeUnit bucket, long periodSecs, int burst) { - super(placebo, replication, bucketMins, periodSecs, burst); + super(placebo, replication, bucket, periodSecs, burst); } @Override diff --git a/cmds/statsd/tools/loadtest/src/com/android/statsd/loadtest/ConfigFactory.java b/cmds/statsd/tools/loadtest/src/com/android/statsd/loadtest/ConfigFactory.java index 4bd284448446..b492ea9c8f69 100644 --- a/cmds/statsd/tools/loadtest/src/com/android/statsd/loadtest/ConfigFactory.java +++ b/cmds/statsd/tools/loadtest/src/com/android/statsd/loadtest/ConfigFactory.java @@ -31,6 +31,7 @@ import com.android.internal.os.StatsdConfigProto.FieldValueMatcher; import com.android.internal.os.StatsdConfigProto.AtomMatcher; import com.android.internal.os.StatsdConfigProto.SimplePredicate; import com.android.internal.os.StatsdConfigProto.StatsdConfig; +import com.android.internal.os.StatsdConfigProto.TimeUnit; import java.io.InputStream; import java.io.IOException; @@ -82,7 +83,7 @@ public class ConfigFactory { * @param placebo If true, only return an empty config * @return The serialized config */ - public byte[] getConfig(int replication, long bucketMillis, boolean placebo, boolean includeCount, + public byte[] getConfig(int replication, TimeUnit bucket, boolean placebo, boolean includeCount, boolean includeDuration, boolean includeEvent, boolean includeValue, boolean includeGauge) { StatsdConfig.Builder config = StatsdConfig.newBuilder() @@ -101,25 +102,25 @@ public class ConfigFactory { } if (includeCount) { for (CountMetric metric : mTemplate.getCountMetricList()) { - addCountMetric(metric, i, bucketMillis, config); + addCountMetric(metric, i, bucket, config); numMetrics++; } } if (includeDuration) { for (DurationMetric metric : mTemplate.getDurationMetricList()) { - addDurationMetric(metric, i, bucketMillis, config); + addDurationMetric(metric, i, bucket, config); numMetrics++; } } if (includeGauge) { for (GaugeMetric metric : mTemplate.getGaugeMetricList()) { - addGaugeMetric(metric, i, bucketMillis, config); + addGaugeMetric(metric, i, bucket, config); numMetrics++; } } if (includeValue) { for (ValueMetric metric : mTemplate.getValueMetricList()) { - addValueMetric(metric, i, bucketMillis, config); + addValueMetric(metric, i, bucket, config); numMetrics++; } } @@ -173,17 +174,11 @@ public class ConfigFactory { config.addEventMetric(metric); } - private Bucket getBucket(long bucketMillis) { - return Bucket.newBuilder() - .setBucketSizeMillis(bucketMillis) - .build(); - } - /** * Creates a {@link CountMetric} based on the template. Makes sure that all names are appended * with the provided suffix, and overrides the bucket size. Then adds that metric to the config. */ - private void addCountMetric(CountMetric template, int suffix, long bucketMillis, + private void addCountMetric(CountMetric template, int suffix, TimeUnit bucket, StatsdConfig.Builder config) { CountMetric.Builder metric = template.toBuilder() .setId(template.getId() + suffix) @@ -196,7 +191,7 @@ public class ConfigFactory { metric.clearLinks(); metric.addAllLinks(links); } - metric.setBucket(getBucket(bucketMillis)); + metric.setBucket(bucket); config.addCountMetric(metric); } @@ -204,7 +199,7 @@ public class ConfigFactory { * Creates a {@link DurationMetric} based on the template. Makes sure that all names are appended * with the provided suffix, and overrides the bucket size. Then adds that metric to the config. */ - private void addDurationMetric(DurationMetric template, int suffix, long bucketMillis, + private void addDurationMetric(DurationMetric template, int suffix, TimeUnit bucket, StatsdConfig.Builder config) { DurationMetric.Builder metric = template.toBuilder() .setId(template.getId() + suffix) @@ -217,7 +212,7 @@ public class ConfigFactory { metric.clearLinks(); metric.addAllLinks(links); } - metric.setBucket(getBucket(bucketMillis)); + metric.setBucket(bucket); config.addDurationMetric(metric); } @@ -225,7 +220,7 @@ public class ConfigFactory { * Creates a {@link GaugeMetric} based on the template. Makes sure that all names are appended * with the provided suffix, and overrides the bucket size. Then adds that metric to the config. */ - private void addGaugeMetric(GaugeMetric template, int suffix, long bucketMillis, + private void addGaugeMetric(GaugeMetric template, int suffix, TimeUnit bucket, StatsdConfig.Builder config) { GaugeMetric.Builder metric = template.toBuilder() .setId(template.getId() + suffix) @@ -238,7 +233,7 @@ public class ConfigFactory { metric.clearLinks(); metric.addAllLinks(links); } - metric.setBucket(getBucket(bucketMillis)); + metric.setBucket(bucket); config.addGaugeMetric(metric); } @@ -246,7 +241,7 @@ public class ConfigFactory { * Creates a {@link ValueMetric} based on the template. Makes sure that all names are appended * with the provided suffix, and overrides the bucket size. Then adds that metric to the config. */ - private void addValueMetric(ValueMetric template, int suffix, long bucketMillis, + private void addValueMetric(ValueMetric template, int suffix, TimeUnit bucket, StatsdConfig.Builder config) { ValueMetric.Builder metric = template.toBuilder() .setId(template.getId() + suffix) @@ -259,7 +254,7 @@ public class ConfigFactory { metric.clearLinks(); metric.addAllLinks(links); } - metric.setBucket(getBucket(bucketMillis)); + metric.setBucket(bucket); config.addValueMetric(metric); } diff --git a/cmds/statsd/tools/loadtest/src/com/android/statsd/loadtest/LoadtestActivity.java b/cmds/statsd/tools/loadtest/src/com/android/statsd/loadtest/LoadtestActivity.java index 86da16c82e9b..056ac0cd3a8a 100644 --- a/cmds/statsd/tools/loadtest/src/com/android/statsd/loadtest/LoadtestActivity.java +++ b/cmds/statsd/tools/loadtest/src/com/android/statsd/loadtest/LoadtestActivity.java @@ -47,6 +47,7 @@ import android.widget.Toast; import com.android.os.StatsLog.ConfigMetricsReport; import com.android.os.StatsLog.ConfigMetricsReportList; import com.android.os.StatsLog.StatsdStatsReport; +import com.android.internal.os.StatsdConfigProto.TimeUnit; import java.util.List; /** @@ -169,7 +170,7 @@ public class LoadtestActivity extends Activity { private long mPeriodSecs; /** The bucket size, in minutes, for aggregate metrics. */ - private long mBucketMins; + private TimeUnit mBucket; /** The duration, in minutes, of the loadtest. */ private long mDurationMins; @@ -360,7 +361,7 @@ public class LoadtestActivity extends Activity { getData(); // Create a config and push it to statsd. - if (!setConfig(mFactory.getConfig(mReplication, mBucketMins * 60 * 1000, mPlacebo, + if (!setConfig(mFactory.getConfig(mReplication, mBucket, mPlacebo, mIncludeCountMetric, mIncludeDurationMetric, mIncludeEventMetric, mIncludeValueMetric, mIncludeGaugeMetric))) { return; @@ -377,7 +378,7 @@ public class LoadtestActivity extends Activity { scheduleNext(); // Start tracking performance. - mPerfData = new PerfData(this, mPlacebo, mReplication, mBucketMins, mPeriodSecs, mBurst); + mPerfData = new PerfData(this, mPlacebo, mReplication, mBucket, mPeriodSecs, mBurst); mPerfData.startRecording(this); mReportText.setText("Loadtest in progress."); @@ -483,8 +484,8 @@ public class LoadtestActivity extends Activity { mPeriodSecs = periodSecs; } - private synchronized void setBucketMins(long bucketMins) { - mBucketMins = bucketMins; + private synchronized void setBucket(TimeUnit bucket) { + mBucket = bucket; } private synchronized void setBurst(int burst) { @@ -536,12 +537,12 @@ public class LoadtestActivity extends Activity { } private void initBucket() { - mBucketMins = getResources().getInteger(R.integer.bucket_default); + mBucket = TimeUnit.valueOf(getResources().getInteger(R.integer.bucket_default)); mBucketText = (EditText) findViewById(R.id.bucket); - mBucketText.addTextChangedListener(new NumericalWatcher(mBucketText, 1, 24 * 60) { + mBucketText.addTextChangedListener(new NumericalWatcher(mBucketText, 1, 9) { @Override public void onNewValue(int newValue) { - setBucketMins(newValue); + setBucket(TimeUnit.valueOf(newValue)); } }); handleFocus(mBucketText); diff --git a/cmds/statsd/tools/loadtest/src/com/android/statsd/loadtest/MemoryDataRecorder.java b/cmds/statsd/tools/loadtest/src/com/android/statsd/loadtest/MemoryDataRecorder.java index d9513a15208a..66bcbffdbcb5 100644 --- a/cmds/statsd/tools/loadtest/src/com/android/statsd/loadtest/MemoryDataRecorder.java +++ b/cmds/statsd/tools/loadtest/src/com/android/statsd/loadtest/MemoryDataRecorder.java @@ -18,6 +18,7 @@ package com.android.statsd.loadtest; import android.content.Context; import android.os.SystemClock; import android.util.Log; +import com.android.internal.os.StatsdConfigProto.TimeUnit; public class MemoryDataRecorder extends PerfDataRecorder { private static final String TAG = "loadtest.MemoryDataDataRecorder"; @@ -26,9 +27,9 @@ public class MemoryDataRecorder extends PerfDataRecorder { private long mStartTimeMillis; private StringBuilder mSb; - public MemoryDataRecorder(boolean placebo, int replication, long bucketMins, long periodSecs, + public MemoryDataRecorder(boolean placebo, int replication, TimeUnit bucket, long periodSecs, int burst) { - super(placebo, replication, bucketMins, periodSecs, burst); + super(placebo, replication, bucket, periodSecs, burst); } @Override diff --git a/cmds/statsd/tools/loadtest/src/com/android/statsd/loadtest/PerfData.java b/cmds/statsd/tools/loadtest/src/com/android/statsd/loadtest/PerfData.java index 22ba9c5aca39..4b4e36873a5c 100644 --- a/cmds/statsd/tools/loadtest/src/com/android/statsd/loadtest/PerfData.java +++ b/cmds/statsd/tools/loadtest/src/com/android/statsd/loadtest/PerfData.java @@ -15,6 +15,8 @@ */ package com.android.statsd.loadtest; +import com.android.internal.os.StatsdConfigProto.TimeUnit; + import android.annotation.Nullable; import android.app.AlarmManager; import android.app.PendingIntent; @@ -52,14 +54,14 @@ public class PerfData extends PerfDataRecorder { private final Set<PerfDataRecorder> mRecorders; public PerfData(LoadtestActivity loadtestActivity, boolean placebo, int replication, - long bucketMins, long periodSecs, int burst) { - super(placebo, replication, bucketMins, periodSecs, burst); + TimeUnit bucket, long periodSecs, int burst) { + super(placebo, replication, bucket, periodSecs, burst); mRecorders = new HashSet(); - mRecorders.add(new BatteryDataRecorder(placebo, replication, bucketMins, periodSecs, burst)); - mRecorders.add(new MemoryDataRecorder(placebo, replication, bucketMins, periodSecs, burst)); - mRecorders.add(new StatsdStatsRecorder(loadtestActivity, placebo, replication, bucketMins, + mRecorders.add(new BatteryDataRecorder(placebo, replication, bucket, periodSecs, burst)); + mRecorders.add(new MemoryDataRecorder(placebo, replication, bucket, periodSecs, burst)); + mRecorders.add(new StatsdStatsRecorder(loadtestActivity, placebo, replication, bucket, periodSecs, burst)); - mRecorders.add(new ValidationRecorder(loadtestActivity, placebo, replication, bucketMins, + mRecorders.add(new ValidationRecorder(loadtestActivity, placebo, replication, bucket, periodSecs, burst)); mAlarmMgr = (AlarmManager) loadtestActivity.getSystemService(Context.ALARM_SERVICE); } diff --git a/cmds/statsd/tools/loadtest/src/com/android/statsd/loadtest/PerfDataRecorder.java b/cmds/statsd/tools/loadtest/src/com/android/statsd/loadtest/PerfDataRecorder.java index 5b5ba3766d04..fd182adfa869 100644 --- a/cmds/statsd/tools/loadtest/src/com/android/statsd/loadtest/PerfDataRecorder.java +++ b/cmds/statsd/tools/loadtest/src/com/android/statsd/loadtest/PerfDataRecorder.java @@ -21,6 +21,7 @@ import android.os.Environment; import android.util.Log; import android.os.Debug; +import com.android.internal.os.StatsdConfigProto.TimeUnit; import java.io.BufferedReader; import java.io.Closeable; import java.io.File; @@ -38,10 +39,10 @@ public abstract class PerfDataRecorder { protected final String mTimeAsString; protected final String mColumnSuffix; - protected PerfDataRecorder(boolean placebo, int replication, long bucketMins, long periodSecs, + protected PerfDataRecorder(boolean placebo, int replication, TimeUnit bucket, long periodSecs, int burst) { mTimeAsString = new SimpleDateFormat("YYYY_MM_dd_HH_mm_ss").format(new Date()); - mColumnSuffix = getColumnSuffix(placebo, replication, bucketMins, periodSecs, burst); + mColumnSuffix = getColumnSuffix(placebo, replication, bucket, periodSecs, burst); } /** Starts recording performance data. */ @@ -120,12 +121,12 @@ public abstract class PerfDataRecorder { } /** Gets the suffix to use in the column name for perf data. */ - private String getColumnSuffix(boolean placebo, int replication, long bucketMins, + private String getColumnSuffix(boolean placebo, int replication, TimeUnit bucket, long periodSecs, int burst) { if (placebo) { return "_placebo_p=" + periodSecs; } - return "_r=" + replication + "_bkt=" + bucketMins + "_p=" + periodSecs + "_bst=" + burst; + return "_r=" + replication + "_bkt=" + bucket + "_p=" + periodSecs + "_bst=" + burst; } diff --git a/cmds/statsd/tools/loadtest/src/com/android/statsd/loadtest/StatsdStatsRecorder.java b/cmds/statsd/tools/loadtest/src/com/android/statsd/loadtest/StatsdStatsRecorder.java index 4ef5dc2f6ca8..1e30fdfbc656 100644 --- a/cmds/statsd/tools/loadtest/src/com/android/statsd/loadtest/StatsdStatsRecorder.java +++ b/cmds/statsd/tools/loadtest/src/com/android/statsd/loadtest/StatsdStatsRecorder.java @@ -18,6 +18,7 @@ package com.android.statsd.loadtest; import android.content.Context; import android.util.Log; import com.android.os.StatsLog.StatsdStatsReport; +import com.android.internal.os.StatsdConfigProto.TimeUnit; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -27,8 +28,8 @@ public class StatsdStatsRecorder extends PerfDataRecorder { private final LoadtestActivity mLoadtestActivity; public StatsdStatsRecorder(LoadtestActivity loadtestActivity, boolean placebo, int replication, - long bucketMins, long periodSecs, int burst) { - super(placebo, replication, bucketMins, periodSecs, burst); + TimeUnit bucket, long periodSecs, int burst) { + super(placebo, replication, bucket, periodSecs, burst); mLoadtestActivity = loadtestActivity; } diff --git a/cmds/statsd/tools/loadtest/src/com/android/statsd/loadtest/ValidationRecorder.java b/cmds/statsd/tools/loadtest/src/com/android/statsd/loadtest/ValidationRecorder.java index d122654ec8a1..5d26be35aa15 100644 --- a/cmds/statsd/tools/loadtest/src/com/android/statsd/loadtest/ValidationRecorder.java +++ b/cmds/statsd/tools/loadtest/src/com/android/statsd/loadtest/ValidationRecorder.java @@ -20,6 +20,7 @@ import android.util.Log; import com.android.os.StatsLog.ConfigMetricsReport; import com.android.os.StatsLog.EventMetricData; import com.android.os.StatsLog.StatsLogReport; +import com.android.internal.os.StatsdConfigProto.TimeUnit; import java.util.List; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -33,8 +34,8 @@ public class ValidationRecorder extends PerfDataRecorder { private final LoadtestActivity mLoadtestActivity; public ValidationRecorder(LoadtestActivity loadtestActivity, boolean placebo, int replication, - long bucketMins, long periodSecs, int burst) { - super(placebo, replication, bucketMins, periodSecs, burst); + TimeUnit bucket, long periodSecs, int burst) { + super(placebo, replication, bucket, periodSecs, burst); mLoadtestActivity = loadtestActivity; } |