From cfed20bce8a66bde6ad0d74a44fc0a2764b2886d Mon Sep 17 00:00:00 2001 From: Stefan Lafon Date: Sat, 18 Nov 2017 09:26:53 -0800 Subject: [PATCH] Update statsd_config.proto. Test: Ran statsd tests. Change-Id: I3a83bdfb38be82d70ca547825152370df8bca9cc --- cmds/statsd/src/condition/condition_util.cpp | 3 ++ cmds/statsd/src/config/ConfigManager.cpp | 12 ++--- cmds/statsd/src/matchers/matcher_util.cpp | 3 ++ cmds/statsd/src/metrics/DurationMetricProducer.cpp | 6 +-- cmds/statsd/src/statsd_config.proto | 60 +++++++++++----------- 5 files changed, 46 insertions(+), 38 deletions(-) diff --git a/cmds/statsd/src/condition/condition_util.cpp b/cmds/statsd/src/condition/condition_util.cpp index 2618a217c378..669a4b77f3b4 100644 --- a/cmds/statsd/src/condition/condition_util.cpp +++ b/cmds/statsd/src/condition/condition_util.cpp @@ -86,6 +86,9 @@ ConditionState evaluateCombinationCondition(const std::vector& children, case LogicalOperation::NOR: newCondition = hasTrue ? ConditionState::kFalse : ConditionState::kTrue; break; + case LogicalOperation::LOGICAL_OPERATION_UNSPECIFIED: + newCondition = ConditionState::kFalse; + break; } return newCondition; } diff --git a/cmds/statsd/src/config/ConfigManager.cpp b/cmds/statsd/src/config/ConfigManager.cpp index 9680e4ac8109..ccb126da836e 100644 --- a/cmds/statsd/src/config/ConfigManager.cpp +++ b/cmds/statsd/src/config/ConfigManager.cpp @@ -265,7 +265,7 @@ static StatsdConfig build_fake_config() { metric->mutable_bucket()->set_bucket_size_millis(30 * 1000L); // Anomaly threshold for screen-on count. - Alert* alert = config.add_alerts(); + Alert* alert = config.add_alert(); alert->set_name("1"); alert->set_number_of_buckets(6); alert->set_trigger_if_sum_gt(10); @@ -280,7 +280,7 @@ static StatsdConfig build_fake_config() { keyMatcher->set_key(UID_PROCESS_STATE_UID_KEY); // Anomaly threshold for background count. - alert = config.add_alerts(); + alert = config.add_alert(); alert->set_name("2"); alert->set_number_of_buckets(4); alert->set_trigger_if_sum_gt(30); @@ -312,7 +312,7 @@ static StatsdConfig build_fake_config() { DurationMetric* durationMetric = config.add_duration_metric(); durationMetric->set_name("5"); durationMetric->mutable_bucket()->set_bucket_size_millis(30 * 1000L); - durationMetric->set_type(DurationMetric_AggregationType_DURATION_SUM); + durationMetric->set_aggregation_type(DurationMetric_AggregationType_SUM); keyMatcher = durationMetric->add_dimension(); keyMatcher->set_key(WAKE_LOCK_UID_KEY_ID); durationMetric->set_what("WL_HELD_PER_APP_PER_NAME"); @@ -326,7 +326,7 @@ static StatsdConfig build_fake_config() { durationMetric = config.add_duration_metric(); durationMetric->set_name("6"); durationMetric->mutable_bucket()->set_bucket_size_millis(30 * 1000L); - durationMetric->set_type(DurationMetric_AggregationType_DURATION_MAX_SPARSE); + durationMetric->set_aggregation_type(DurationMetric_AggregationType_MAX_SPARSE); keyMatcher = durationMetric->add_dimension(); keyMatcher->set_key(WAKE_LOCK_UID_KEY_ID); durationMetric->set_what("WL_HELD_PER_APP_PER_NAME"); @@ -340,7 +340,7 @@ static StatsdConfig build_fake_config() { durationMetric = config.add_duration_metric(); durationMetric->set_name("7"); durationMetric->mutable_bucket()->set_bucket_size_millis(30 * 1000L); - durationMetric->set_type(DurationMetric_AggregationType_DURATION_MAX_SPARSE); + durationMetric->set_aggregation_type(DurationMetric_AggregationType_MAX_SPARSE); durationMetric->set_what("WL_HELD_PER_APP_PER_NAME"); durationMetric->set_condition("APP_IS_BACKGROUND_AND_SCREEN_ON"); link = durationMetric->add_links(); @@ -352,7 +352,7 @@ static StatsdConfig build_fake_config() { durationMetric = config.add_duration_metric(); durationMetric->set_name("8"); durationMetric->mutable_bucket()->set_bucket_size_millis(10 * 1000L); - durationMetric->set_type(DurationMetric_AggregationType_DURATION_SUM); + durationMetric->set_aggregation_type(DurationMetric_AggregationType_SUM); durationMetric->set_what("SCREEN_IS_ON"); // Value metric to count KERNEL_WAKELOCK when screen turned on diff --git a/cmds/statsd/src/matchers/matcher_util.cpp b/cmds/statsd/src/matchers/matcher_util.cpp index 255165cee7ea..f7352cd1190c 100644 --- a/cmds/statsd/src/matchers/matcher_util.cpp +++ b/cmds/statsd/src/matchers/matcher_util.cpp @@ -84,6 +84,9 @@ bool combinationMatch(const vector& children, const LogicalOperation& opera } } break; + case LogicalOperation::LOGICAL_OPERATION_UNSPECIFIED: + matched = false; + break; } return matched; } diff --git a/cmds/statsd/src/metrics/DurationMetricProducer.cpp b/cmds/statsd/src/metrics/DurationMetricProducer.cpp index 581ca410e1dc..1bccafadee8f 100644 --- a/cmds/statsd/src/metrics/DurationMetricProducer.cpp +++ b/cmds/statsd/src/metrics/DurationMetricProducer.cpp @@ -111,12 +111,12 @@ void DurationMetricProducer::startNewProtoOutputStream(long long startTime) { unique_ptr DurationMetricProducer::createDurationTracker( vector& bucket) { - switch (mMetric.type()) { - case DurationMetric_AggregationType_DURATION_SUM: + switch (mMetric.aggregation_type()) { + case DurationMetric_AggregationType_SUM: return make_unique(mWizard, mConditionTrackerIndex, mNested, mCurrentBucketStartTimeNs, mBucketSizeNs, bucket); - case DurationMetric_AggregationType_DURATION_MAX_SPARSE: + case DurationMetric_AggregationType_MAX_SPARSE: return make_unique(mWizard, mConditionTrackerIndex, mNested, mCurrentBucketStartTimeNs, mBucketSizeNs, bucket); diff --git a/cmds/statsd/src/statsd_config.proto b/cmds/statsd/src/statsd_config.proto index 9a760b1b8ca5..d3b04ba5e32d 100644 --- a/cmds/statsd/src/statsd_config.proto +++ b/cmds/statsd/src/statsd_config.proto @@ -47,6 +47,7 @@ message KeyValueMatcher { } enum LogicalOperation { + LOGICAL_OPERATION_UNSPECIFIED = 0; AND = 1; OR = 2; NOT = 3; @@ -111,23 +112,12 @@ message Bucket { optional int64 bucket_size_millis = 1; } -message Alert { - optional string name = 1; - - optional string metric_name = 2; - - message IncidentdDetails { - repeated int32 section = 1; - } - optional IncidentdDetails incidentd_details = 3; - - optional int32 number_of_buckets = 4; - - optional int32 refractory_period_secs = 5; +message EventConditionLink { + optional string condition = 1; - optional int64 trigger_if_sum_gt = 6; + repeated KeyMatcher key_in_main = 2; - optional int32 refractory_period_in_buckets = 7; + repeated KeyMatcher key_in_condition = 3; } message EventMetric { @@ -151,9 +141,7 @@ message CountMetric { optional Bucket bucket = 5; - optional bool include_in_output = 6; - - repeated EventConditionLink links = 7; + repeated EventConditionLink links = 6; } message DurationMetric { @@ -166,11 +154,11 @@ message DurationMetric { repeated EventConditionLink links = 4; enum AggregationType { - DURATION_SUM = 1; + SUM = 1; - DURATION_MAX_SPARSE = 2; + MAX_SPARSE = 2; } - optional AggregationType type = 5; + optional AggregationType aggregation_type = 5 [default = SUM]; repeated KeyMatcher dimension = 6; @@ -208,16 +196,30 @@ message ValueMetric { repeated EventConditionLink links = 7; - enum Operation { SUM = 1; } - optional Operation operation = 9 [default = SUM]; + enum AggregationType { + SUM = 1; + } + optional AggregationType aggregation_type = 8 [default = SUM]; } -message EventConditionLink { - optional string condition = 1; +message Alert { + optional string name = 1; - repeated KeyMatcher key_in_main = 2; - repeated KeyMatcher key_in_condition = 3; -}; + optional string metric_name = 2; + + message IncidentdDetails { + repeated int32 section = 1; + } + optional IncidentdDetails incidentd_details = 3; + + optional int32 number_of_buckets = 4; + + optional int32 refractory_period_secs = 5; + + optional int64 trigger_if_sum_gt = 6; + + optional int32 refractory_period_in_buckets = 7; +} message StatsdConfig { optional string name = 1; @@ -236,5 +238,5 @@ message StatsdConfig { repeated Condition condition = 8; - repeated Alert alerts = 9; + repeated Alert alert = 9; } -- 2.11.0