Merge "Update statsd_config.proto."

This commit is contained in:
Stefan Lafon
2017-11-19 05:04:25 +00:00
committed by Android (Google) Code Review
5 changed files with 46 additions and 38 deletions

View File

@@ -86,6 +86,9 @@ ConditionState evaluateCombinationCondition(const std::vector<int>& children,
case LogicalOperation::NOR:
newCondition = hasTrue ? ConditionState::kFalse : ConditionState::kTrue;
break;
case LogicalOperation::LOGICAL_OPERATION_UNSPECIFIED:
newCondition = ConditionState::kFalse;
break;
}
return newCondition;
}

View File

@@ -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

View File

@@ -84,6 +84,9 @@ bool combinationMatch(const vector<int>& children, const LogicalOperation& opera
}
}
break;
case LogicalOperation::LOGICAL_OPERATION_UNSPECIFIED:
matched = false;
break;
}
return matched;
}

View File

@@ -111,12 +111,12 @@ void DurationMetricProducer::startNewProtoOutputStream(long long startTime) {
unique_ptr<DurationTracker> DurationMetricProducer::createDurationTracker(
vector<DurationBucket>& bucket) {
switch (mMetric.type()) {
case DurationMetric_AggregationType_DURATION_SUM:
switch (mMetric.aggregation_type()) {
case DurationMetric_AggregationType_SUM:
return make_unique<OringDurationTracker>(mWizard, mConditionTrackerIndex, mNested,
mCurrentBucketStartTimeNs, mBucketSizeNs,
bucket);
case DurationMetric_AggregationType_DURATION_MAX_SPARSE:
case DurationMetric_AggregationType_MAX_SPARSE:
return make_unique<MaxDurationTracker>(mWizard, mConditionTrackerIndex, mNested,
mCurrentBucketStartTimeNs, mBucketSizeNs,
bucket);

View File

@@ -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;
message EventConditionLink {
optional string condition = 1;
optional string metric_name = 2;
repeated KeyMatcher key_in_main = 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;
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;
}