Loading cmds/statsd/src/metrics/CountMetricProducer.h +1 −0 Original line number Diff line number Diff line Loading @@ -106,6 +106,7 @@ private: FRIEND_TEST(CountMetricProducerTest, TestEventWithAppUpgrade); FRIEND_TEST(CountMetricProducerTest, TestEventWithAppUpgradeInNextBucket); FRIEND_TEST(CountMetricProducerTest, TestFirstBucket); FRIEND_TEST(CountMetricProducerTest, TestOneWeekTimeUnit); }; } // namespace statsd Loading cmds/statsd/src/stats_log_util.cpp +2 −0 Original line number Diff line number Diff line Loading @@ -445,6 +445,8 @@ int64_t TimeUnitToBucketSizeInMillis(TimeUnit unit) { return 12 * 60 * 60 * 1000LL; case ONE_DAY: return 24 * 60 * 60 * 1000LL; case ONE_WEEK: return 7 * 24 * 60 * 60 * 1000LL; case CTS: return 1000; case TIME_UNIT_UNSPECIFIED: Loading cmds/statsd/src/statsd_config.proto +1 −0 Original line number Diff line number Diff line Loading @@ -44,6 +44,7 @@ enum TimeUnit { SIX_HOURS = 7; TWELVE_HOURS = 8; ONE_DAY = 9; ONE_WEEK = 10; CTS = 1000; } Loading cmds/statsd/tests/metrics/CountMetricProducer_test.cpp +20 −0 Original line number Diff line number Diff line Loading @@ -396,6 +396,26 @@ TEST(CountMetricProducerTest, TestAnomalyDetectionUnSliced) { std::ceil(1.0 * event7.GetElapsedTimestampNs() / NS_PER_SEC + refPeriodSec)); } TEST(CountMetricProducerTest, TestOneWeekTimeUnit) { CountMetric metric; metric.set_id(1); metric.set_bucket(ONE_WEEK); sp<MockConditionWizard> wizard = new NaggyMock<MockConditionWizard>(); int64_t oneDayNs = 24 * 60 * 60 * 1e9; int64_t fiveWeeksNs = 5 * 7 * oneDayNs; CountMetricProducer countProducer( kConfigKey, metric, -1 /* meaning no condition */, wizard, oneDayNs, fiveWeeksNs); int64_t fiveWeeksOneDayNs = fiveWeeksNs + oneDayNs; EXPECT_EQ(fiveWeeksNs, countProducer.mCurrentBucketStartTimeNs); EXPECT_EQ(4, countProducer.mCurrentBucketNum); EXPECT_EQ(fiveWeeksOneDayNs, countProducer.getCurrentBucketEndTimeNs()); } } // namespace statsd } // namespace os } // namespace android Loading Loading
cmds/statsd/src/metrics/CountMetricProducer.h +1 −0 Original line number Diff line number Diff line Loading @@ -106,6 +106,7 @@ private: FRIEND_TEST(CountMetricProducerTest, TestEventWithAppUpgrade); FRIEND_TEST(CountMetricProducerTest, TestEventWithAppUpgradeInNextBucket); FRIEND_TEST(CountMetricProducerTest, TestFirstBucket); FRIEND_TEST(CountMetricProducerTest, TestOneWeekTimeUnit); }; } // namespace statsd Loading
cmds/statsd/src/stats_log_util.cpp +2 −0 Original line number Diff line number Diff line Loading @@ -445,6 +445,8 @@ int64_t TimeUnitToBucketSizeInMillis(TimeUnit unit) { return 12 * 60 * 60 * 1000LL; case ONE_DAY: return 24 * 60 * 60 * 1000LL; case ONE_WEEK: return 7 * 24 * 60 * 60 * 1000LL; case CTS: return 1000; case TIME_UNIT_UNSPECIFIED: Loading
cmds/statsd/src/statsd_config.proto +1 −0 Original line number Diff line number Diff line Loading @@ -44,6 +44,7 @@ enum TimeUnit { SIX_HOURS = 7; TWELVE_HOURS = 8; ONE_DAY = 9; ONE_WEEK = 10; CTS = 1000; } Loading
cmds/statsd/tests/metrics/CountMetricProducer_test.cpp +20 −0 Original line number Diff line number Diff line Loading @@ -396,6 +396,26 @@ TEST(CountMetricProducerTest, TestAnomalyDetectionUnSliced) { std::ceil(1.0 * event7.GetElapsedTimestampNs() / NS_PER_SEC + refPeriodSec)); } TEST(CountMetricProducerTest, TestOneWeekTimeUnit) { CountMetric metric; metric.set_id(1); metric.set_bucket(ONE_WEEK); sp<MockConditionWizard> wizard = new NaggyMock<MockConditionWizard>(); int64_t oneDayNs = 24 * 60 * 60 * 1e9; int64_t fiveWeeksNs = 5 * 7 * oneDayNs; CountMetricProducer countProducer( kConfigKey, metric, -1 /* meaning no condition */, wizard, oneDayNs, fiveWeeksNs); int64_t fiveWeeksOneDayNs = fiveWeeksNs + oneDayNs; EXPECT_EQ(fiveWeeksNs, countProducer.mCurrentBucketStartTimeNs); EXPECT_EQ(4, countProducer.mCurrentBucketNum); EXPECT_EQ(fiveWeeksOneDayNs, countProducer.getCurrentBucketEndTimeNs()); } } // namespace statsd } // namespace os } // namespace android Loading