Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 64d467ec authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "1/ Use FieldMatcher to specify the value fields in value metric. 2/...

Merge "1/ Use FieldMatcher to specify the value fields in value metric. 2/ rename number_of_buckets as num_buckets 3/ use double for the Alert's threshold"
parents 41bbed87 a7fb12d2
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -34,11 +34,11 @@ namespace statsd {
AnomalyTracker::AnomalyTracker(const Alert& alert, const ConfigKey& configKey)
    : mAlert(alert),
      mConfigKey(configKey),
      mNumOfPastBuckets(mAlert.number_of_buckets() - 1) {
      mNumOfPastBuckets(mAlert.num_buckets() - 1) {
    VLOG("AnomalyTracker() called");
    if (mAlert.number_of_buckets() <= 0) {
    if (mAlert.num_buckets() <= 0) {
        ALOGE("Cannot create AnomalyTracker with %lld buckets",
              (long long)mAlert.number_of_buckets());
              (long long)mAlert.num_buckets());
        return;
    }
    if (!mAlert.has_trigger_if_sum_gt()) {
+2 −1
Original line number Diff line number Diff line
@@ -377,7 +377,8 @@ StatsdConfig build_fake_config() {
    ValueMetric* valueMetric = config.add_value_metric();
    valueMetric->set_id(11);
    valueMetric->set_what(109);
    valueMetric->set_value_field(KERNEL_WAKELOCK_COUNT_KEY);
    valueMetric->mutable_value_field()->set_field(KERNEL_WAKELOCK_TAG_ID);
    valueMetric->mutable_value_field()->add_child()->set_field(KERNEL_WAKELOCK_COUNT_KEY);
    valueMetric->set_condition(201);
    dimensions = valueMetric->mutable_dimensions();
    dimensions->set_field(KERNEL_WAKELOCK_TAG_ID);
+17 −0
Original line number Diff line number Diff line
@@ -351,6 +351,23 @@ bool IsSubDimension(const DimensionsValue& dimension, const DimensionsValue& sub
    }
}

long getLongFromDimenValue(const DimensionsValue& dimensionValue) {
    switch (dimensionValue.value_case()) {
        case DimensionsValue::ValueCase::kValueInt:
            return dimensionValue.value_int();
        case DimensionsValue::ValueCase::kValueLong:
            return dimensionValue.value_long();
        case DimensionsValue::ValueCase::kValueBool:
            return dimensionValue.value_bool() ? 1 : 0;
        case DimensionsValue::ValueCase::kValueFloat:
            return (int64_t)dimensionValue.value_float();
        case DimensionsValue::ValueCase::kValueTuple:
        case DimensionsValue::ValueCase::kValueStr:
        case DimensionsValue::ValueCase::VALUE_NOT_SET:
            return 0;
    }
}

}  // namespace statsd
}  // namespace os
}  // namespace android
+2 −0
Original line number Diff line number Diff line
@@ -56,6 +56,8 @@ void DimensionsValueToString(const DimensionsValue& value, std::string *flattene

bool IsSubDimension(const DimensionsValue& dimension, const DimensionsValue& sub);

// Helper function to get long value from the DimensionsValue proto.
long getLongFromDimenValue(const DimensionsValue& dimensionValue);
}  // namespace statsd
}  // namespace os
}  // namespace android
+3 −3
Original line number Diff line number Diff line
@@ -98,9 +98,9 @@ DurationMetricProducer::~DurationMetricProducer() {

sp<AnomalyTracker> DurationMetricProducer::addAnomalyTracker(const Alert &alert) {
    std::lock_guard<std::mutex> lock(mMutex);
    if (alert.trigger_if_sum_gt() > alert.number_of_buckets() * mBucketSizeNs) {
        ALOGW("invalid alert: threshold (%lld) > possible recordable value (%d x %lld)",
              alert.trigger_if_sum_gt(), alert.number_of_buckets(),
    if (alert.trigger_if_sum_gt() > alert.num_buckets() * mBucketSizeNs) {
        ALOGW("invalid alert: threshold (%f) > possible recordable value (%d x %lld)",
              alert.trigger_if_sum_gt(), alert.num_buckets(),
              (long long)mBucketSizeNs);
        return nullptr;
    }
Loading