diff options
| author | 2017-12-04 21:59:14 +0000 | |
|---|---|---|
| committer | 2017-12-04 21:59:14 +0000 | |
| commit | 8a15f4df7730f2211d7615c0cabceb608b8ecf15 (patch) | |
| tree | 3ee699df4e66c3e00a1de8ed9a4160fdfe048d94 | |
| parent | edb95359226a7094bc7ba54d4d66880fe714e228 (diff) | |
| parent | b8c9aa8c9ccba4e64759c177381b742ca99a5487 (diff) | |
Merge "Rename a few things in statsd_config.proto."
17 files changed, 249 insertions, 253 deletions
diff --git a/cmds/statsd/src/config/ConfigManager.cpp b/cmds/statsd/src/config/ConfigManager.cpp index 4b7e49a80336..c6fc2755156e 100644 --- a/cmds/statsd/src/config/ConfigManager.cpp +++ b/cmds/statsd/src/config/ConfigManager.cpp @@ -348,69 +348,69 @@ StatsdConfig build_fake_config() { gaugeMetric->mutable_bucket()->set_bucket_size_millis(60 * 1000L); // Event matchers............ - LogEntryMatcher* temperatureEntryMatcher = config.add_log_entry_matcher(); - temperatureEntryMatcher->set_name("DEVICE_TEMPERATURE"); - temperatureEntryMatcher->mutable_simple_log_entry_matcher()->set_tag( + AtomMatcher* temperatureAtomMatcher = config.add_atom_matcher(); + temperatureAtomMatcher->set_name("DEVICE_TEMPERATURE"); + temperatureAtomMatcher->mutable_simple_atom_matcher()->set_tag( DEVICE_TEMPERATURE_TAG_ID); - LogEntryMatcher* eventMatcher = config.add_log_entry_matcher(); + AtomMatcher* eventMatcher = config.add_atom_matcher(); eventMatcher->set_name("SCREEN_TURNED_ON"); - SimpleLogEntryMatcher* simpleLogEntryMatcher = eventMatcher->mutable_simple_log_entry_matcher(); - simpleLogEntryMatcher->set_tag(SCREEN_EVENT_TAG_ID); - KeyValueMatcher* keyValueMatcher = simpleLogEntryMatcher->add_key_value_matcher(); + SimpleAtomMatcher* simpleAtomMatcher = eventMatcher->mutable_simple_atom_matcher(); + simpleAtomMatcher->set_tag(SCREEN_EVENT_TAG_ID); + KeyValueMatcher* keyValueMatcher = simpleAtomMatcher->add_key_value_matcher(); keyValueMatcher->mutable_key_matcher()->set_key(SCREEN_EVENT_STATE_KEY); keyValueMatcher->set_eq_int(SCREEN_EVENT_ON_VALUE); - eventMatcher = config.add_log_entry_matcher(); + eventMatcher = config.add_atom_matcher(); eventMatcher->set_name("SCREEN_TURNED_OFF"); - simpleLogEntryMatcher = eventMatcher->mutable_simple_log_entry_matcher(); - simpleLogEntryMatcher->set_tag(SCREEN_EVENT_TAG_ID); - keyValueMatcher = simpleLogEntryMatcher->add_key_value_matcher(); + simpleAtomMatcher = eventMatcher->mutable_simple_atom_matcher(); + simpleAtomMatcher->set_tag(SCREEN_EVENT_TAG_ID); + keyValueMatcher = simpleAtomMatcher->add_key_value_matcher(); keyValueMatcher->mutable_key_matcher()->set_key(SCREEN_EVENT_STATE_KEY); keyValueMatcher->set_eq_int(SCREEN_EVENT_OFF_VALUE); - eventMatcher = config.add_log_entry_matcher(); + eventMatcher = config.add_atom_matcher(); eventMatcher->set_name("PROCESS_STATE_CHANGE"); - simpleLogEntryMatcher = eventMatcher->mutable_simple_log_entry_matcher(); - simpleLogEntryMatcher->set_tag(UID_PROCESS_STATE_TAG_ID); + simpleAtomMatcher = eventMatcher->mutable_simple_atom_matcher(); + simpleAtomMatcher->set_tag(UID_PROCESS_STATE_TAG_ID); - eventMatcher = config.add_log_entry_matcher(); + eventMatcher = config.add_atom_matcher(); eventMatcher->set_name("APP_GOES_BACKGROUND"); - simpleLogEntryMatcher = eventMatcher->mutable_simple_log_entry_matcher(); - simpleLogEntryMatcher->set_tag(APP_USAGE_ID); - keyValueMatcher = simpleLogEntryMatcher->add_key_value_matcher(); + simpleAtomMatcher = eventMatcher->mutable_simple_atom_matcher(); + simpleAtomMatcher->set_tag(APP_USAGE_ID); + keyValueMatcher = simpleAtomMatcher->add_key_value_matcher(); keyValueMatcher->mutable_key_matcher()->set_key(APP_USAGE_STATE_KEY); keyValueMatcher->set_eq_int(APP_USAGE_BACKGROUND); - eventMatcher = config.add_log_entry_matcher(); + eventMatcher = config.add_atom_matcher(); eventMatcher->set_name("APP_GOES_FOREGROUND"); - simpleLogEntryMatcher = eventMatcher->mutable_simple_log_entry_matcher(); - simpleLogEntryMatcher->set_tag(APP_USAGE_ID); - keyValueMatcher = simpleLogEntryMatcher->add_key_value_matcher(); + simpleAtomMatcher = eventMatcher->mutable_simple_atom_matcher(); + simpleAtomMatcher->set_tag(APP_USAGE_ID); + keyValueMatcher = simpleAtomMatcher->add_key_value_matcher(); keyValueMatcher->mutable_key_matcher()->set_key(APP_USAGE_STATE_KEY); keyValueMatcher->set_eq_int(APP_USAGE_FOREGROUND); - eventMatcher = config.add_log_entry_matcher(); + eventMatcher = config.add_atom_matcher(); eventMatcher->set_name("APP_GET_WL"); - simpleLogEntryMatcher = eventMatcher->mutable_simple_log_entry_matcher(); - simpleLogEntryMatcher->set_tag(WAKE_LOCK_TAG_ID); - keyValueMatcher = simpleLogEntryMatcher->add_key_value_matcher(); + simpleAtomMatcher = eventMatcher->mutable_simple_atom_matcher(); + simpleAtomMatcher->set_tag(WAKE_LOCK_TAG_ID); + keyValueMatcher = simpleAtomMatcher->add_key_value_matcher(); keyValueMatcher->mutable_key_matcher()->set_key(WAKE_LOCK_STATE_KEY); keyValueMatcher->set_eq_int(WAKE_LOCK_ACQUIRE_VALUE); - eventMatcher = config.add_log_entry_matcher(); + eventMatcher = config.add_atom_matcher(); eventMatcher->set_name("APP_RELEASE_WL"); - simpleLogEntryMatcher = eventMatcher->mutable_simple_log_entry_matcher(); - simpleLogEntryMatcher->set_tag(WAKE_LOCK_TAG_ID); - keyValueMatcher = simpleLogEntryMatcher->add_key_value_matcher(); + simpleAtomMatcher = eventMatcher->mutable_simple_atom_matcher(); + simpleAtomMatcher->set_tag(WAKE_LOCK_TAG_ID); + keyValueMatcher = simpleAtomMatcher->add_key_value_matcher(); keyValueMatcher->mutable_key_matcher()->set_key(WAKE_LOCK_STATE_KEY); keyValueMatcher->set_eq_int(WAKE_LOCK_RELEASE_VALUE); // pulled events - eventMatcher = config.add_log_entry_matcher(); + eventMatcher = config.add_atom_matcher(); eventMatcher->set_name("KERNEL_WAKELOCK"); - simpleLogEntryMatcher = eventMatcher->mutable_simple_log_entry_matcher(); - simpleLogEntryMatcher->set_tag(KERNEL_WAKELOCK_TAG_ID); + simpleAtomMatcher = eventMatcher->mutable_simple_atom_matcher(); + simpleAtomMatcher->set_tag(KERNEL_WAKELOCK_TAG_ID); // Conditions............. Condition* condition = config.add_condition(); diff --git a/cmds/statsd/src/matchers/CombinationLogMatchingTracker.cpp b/cmds/statsd/src/matchers/CombinationLogMatchingTracker.cpp index 78ba762047b8..51a38b61ccf2 100644 --- a/cmds/statsd/src/matchers/CombinationLogMatchingTracker.cpp +++ b/cmds/statsd/src/matchers/CombinationLogMatchingTracker.cpp @@ -36,7 +36,7 @@ CombinationLogMatchingTracker::CombinationLogMatchingTracker(const string& name, CombinationLogMatchingTracker::~CombinationLogMatchingTracker() { } -bool CombinationLogMatchingTracker::init(const vector<LogEntryMatcher>& allLogMatchers, +bool CombinationLogMatchingTracker::init(const vector<AtomMatcher>& allLogMatchers, const vector<sp<LogMatchingTracker>>& allTrackers, const unordered_map<string, int>& matcherMap, vector<bool>& stack) { @@ -47,7 +47,7 @@ bool CombinationLogMatchingTracker::init(const vector<LogEntryMatcher>& allLogMa // mark this node as visited in the recursion stack. stack[mIndex] = true; - LogEntryMatcher_Combination matcher = allLogMatchers[mIndex].combination(); + AtomMatcher_Combination matcher = allLogMatchers[mIndex].combination(); // LogicalOperation is missing in the config if (!matcher.has_operation()) { diff --git a/cmds/statsd/src/matchers/CombinationLogMatchingTracker.h b/cmds/statsd/src/matchers/CombinationLogMatchingTracker.h index adb691e9568e..81f6e8052ebc 100644 --- a/cmds/statsd/src/matchers/CombinationLogMatchingTracker.h +++ b/cmds/statsd/src/matchers/CombinationLogMatchingTracker.h @@ -28,12 +28,12 @@ namespace android { namespace os { namespace statsd { -// Represents a LogEntryMatcher_Combination in the StatsdConfig. +// Represents a AtomMatcher_Combination in the StatsdConfig. class CombinationLogMatchingTracker : public virtual LogMatchingTracker { public: CombinationLogMatchingTracker(const std::string& name, const int index); - bool init(const std::vector<LogEntryMatcher>& allLogMatchers, + bool init(const std::vector<AtomMatcher>& allLogMatchers, const std::vector<sp<LogMatchingTracker>>& allTrackers, const std::unordered_map<std::string, int>& matcherMap, std::vector<bool>& stack); diff --git a/cmds/statsd/src/matchers/LogMatchingTracker.h b/cmds/statsd/src/matchers/LogMatchingTracker.h index fea3e9b367ef..8162c443fbd3 100644 --- a/cmds/statsd/src/matchers/LogMatchingTracker.h +++ b/cmds/statsd/src/matchers/LogMatchingTracker.h @@ -39,14 +39,14 @@ public: virtual ~LogMatchingTracker(){}; // Initialize this LogMatchingTracker. - // allLogMatchers: the list of the LogEntryMatcher proto config. This is needed because we don't + // allLogMatchers: the list of the AtomMatcher proto config. This is needed because we don't // store the proto object in memory. We only need it during initilization. // allTrackers: the list of the LogMatchingTracker objects. It's a one-to-one mapping with // allLogMatchers. This is needed because the initialization is done recursively // for CombinationLogMatchingTrackers using DFS. // stack: a bit map to record which matcher has been visited on the stack. This is for detecting // circle dependency. - virtual bool init(const std::vector<LogEntryMatcher>& allLogMatchers, + virtual bool init(const std::vector<AtomMatcher>& allLogMatchers, const std::vector<sp<LogMatchingTracker>>& allTrackers, const std::unordered_map<std::string, int>& matcherMap, std::vector<bool>& stack) = 0; diff --git a/cmds/statsd/src/matchers/SimpleLogMatchingTracker.cpp b/cmds/statsd/src/matchers/SimpleLogMatchingTracker.cpp index ad37b010d1fb..ac217abecba3 100644 --- a/cmds/statsd/src/matchers/SimpleLogMatchingTracker.cpp +++ b/cmds/statsd/src/matchers/SimpleLogMatchingTracker.cpp @@ -30,7 +30,7 @@ using std::vector; SimpleLogMatchingTracker::SimpleLogMatchingTracker(const string& name, const int index, - const SimpleLogEntryMatcher& matcher) + const SimpleAtomMatcher& matcher) : LogMatchingTracker(name, index), mMatcher(matcher) { if (!matcher.has_tag()) { mInitialized = false; @@ -43,7 +43,7 @@ SimpleLogMatchingTracker::SimpleLogMatchingTracker(const string& name, const int SimpleLogMatchingTracker::~SimpleLogMatchingTracker() { } -bool SimpleLogMatchingTracker::init(const vector<LogEntryMatcher>& allLogMatchers, +bool SimpleLogMatchingTracker::init(const vector<AtomMatcher>& allLogMatchers, const vector<sp<LogMatchingTracker>>& allTrackers, const unordered_map<string, int>& matcherMap, vector<bool>& stack) { diff --git a/cmds/statsd/src/matchers/SimpleLogMatchingTracker.h b/cmds/statsd/src/matchers/SimpleLogMatchingTracker.h index 5dca55ed8d45..2c188c18c95b 100644 --- a/cmds/statsd/src/matchers/SimpleLogMatchingTracker.h +++ b/cmds/statsd/src/matchers/SimpleLogMatchingTracker.h @@ -32,11 +32,11 @@ namespace statsd { class SimpleLogMatchingTracker : public virtual LogMatchingTracker { public: SimpleLogMatchingTracker(const std::string& name, const int index, - const SimpleLogEntryMatcher& matcher); + const SimpleAtomMatcher& matcher); ~SimpleLogMatchingTracker(); - bool init(const std::vector<LogEntryMatcher>& allLogMatchers, + bool init(const std::vector<AtomMatcher>& allLogMatchers, const std::vector<sp<LogMatchingTracker>>& allTrackers, const std::unordered_map<std::string, int>& matcherMap, std::vector<bool>& stack) override; @@ -46,7 +46,7 @@ public: std::vector<MatchingState>& matcherResults) override; private: - const SimpleLogEntryMatcher mMatcher; + const SimpleAtomMatcher mMatcher; }; } // namespace statsd diff --git a/cmds/statsd/src/matchers/matcher_util.cpp b/cmds/statsd/src/matchers/matcher_util.cpp index f7352cd1190c..534d54eb0bea 100644 --- a/cmds/statsd/src/matchers/matcher_util.cpp +++ b/cmds/statsd/src/matchers/matcher_util.cpp @@ -91,7 +91,7 @@ bool combinationMatch(const vector<int>& children, const LogicalOperation& opera return matched; } -bool matchesSimple(const SimpleLogEntryMatcher& simpleMatcher, const LogEvent& event) { +bool matchesSimple(const SimpleAtomMatcher& simpleMatcher, const LogEvent& event) { const int tagId = event.GetTagId(); if (simpleMatcher.tag() != tagId) { diff --git a/cmds/statsd/src/matchers/matcher_util.h b/cmds/statsd/src/matchers/matcher_util.h index 4ea6f0b4a3ed..f54ab3648a19 100644 --- a/cmds/statsd/src/matchers/matcher_util.h +++ b/cmds/statsd/src/matchers/matcher_util.h @@ -42,7 +42,7 @@ enum MatchingState { bool combinationMatch(const std::vector<int>& children, const LogicalOperation& operation, const std::vector<MatchingState>& matcherResults); -bool matchesSimple(const SimpleLogEntryMatcher& simpleMatcher, const LogEvent& wrapper); +bool matchesSimple(const SimpleAtomMatcher& simpleMatcher, const LogEvent& wrapper); std::vector<KeyValuePair> getDimensionKey(const LogEvent& event, const std::vector<KeyMatcher>& dimensions); diff --git a/cmds/statsd/src/metrics/DurationMetricProducer.h b/cmds/statsd/src/metrics/DurationMetricProducer.h index 8e32d148e221..1c0dedcd6ade 100644 --- a/cmds/statsd/src/metrics/DurationMetricProducer.h +++ b/cmds/statsd/src/metrics/DurationMetricProducer.h @@ -79,13 +79,13 @@ private: const DurationMetric mMetric; - // Index of the SimpleLogEntryMatcher which defines the start. + // Index of the SimpleAtomMatcher which defines the start. const size_t mStartIndex; - // Index of the SimpleLogEntryMatcher which defines the stop. + // Index of the SimpleAtomMatcher which defines the stop. const size_t mStopIndex; - // Index of the SimpleLogEntryMatcher which defines the stop all for all dimensions. + // Index of the SimpleAtomMatcher which defines the stop all for all dimensions. const size_t mStopAllIndex; // nest counting -- for the same key, stops must match the number of starts to make real stop @@ -118,4 +118,3 @@ private: } // namespace statsd } // namespace os } // namespace android - diff --git a/cmds/statsd/src/metrics/MetricsManager.cpp b/cmds/statsd/src/metrics/MetricsManager.cpp index 8da8316a7225..9fdc6fa996da 100644 --- a/cmds/statsd/src/metrics/MetricsManager.cpp +++ b/cmds/statsd/src/metrics/MetricsManager.cpp @@ -39,7 +39,7 @@ namespace statsd { MetricsManager::MetricsManager(const ConfigKey& key, const StatsdConfig& config) : mConfigKey(key) { mConfigValid = - initStatsdConfig(key, config, mTagIds, mAllLogEntryMatchers, mAllConditionTrackers, + initStatsdConfig(key, config, mTagIds, mAllAtomMatchers, mAllConditionTrackers, mAllMetricProducers, mAllAnomalyTrackers, mConditionToMetricMap, mTrackerToMetricMap, mTrackerToConditionMap); @@ -47,11 +47,11 @@ MetricsManager::MetricsManager(const ConfigKey& key, const StatsdConfig& config) // no matter whether this config is valid, log it in the stats. StatsdStats::getInstance().noteConfigReceived(key, mAllMetricProducers.size(), mAllConditionTrackers.size(), - mAllLogEntryMatchers.size(), 0, mConfigValid); + mAllAtomMatchers.size(), 0, mConfigValid); // Guardrail. Reject the config if it's too big. if (mAllMetricProducers.size() > StatsdStats::kMaxMetricCountPerConfig || mAllConditionTrackers.size() > StatsdStats::kMaxConditionCountPerConfig || - mAllLogEntryMatchers.size() > StatsdStats::kMaxMatcherCountPerConfig) { + mAllAtomMatchers.size() > StatsdStats::kMaxMatcherCountPerConfig) { ALOGE("This config is too big! Reject!"); mConfigValid = false; } @@ -95,10 +95,10 @@ void MetricsManager::onLogEvent(const LogEvent& event) { return; } - vector<MatchingState> matcherCache(mAllLogEntryMatchers.size(), MatchingState::kNotComputed); + vector<MatchingState> matcherCache(mAllAtomMatchers.size(), MatchingState::kNotComputed); - for (auto& matcher : mAllLogEntryMatchers) { - matcher->onLogEvent(event, mAllLogEntryMatchers, matcherCache); + for (auto& matcher : mAllAtomMatchers) { + matcher->onLogEvent(event, mAllAtomMatchers, matcherCache); } // A bitmap to see which ConditionTracker needs to be re-evaluated. @@ -149,11 +149,11 @@ void MetricsManager::onLogEvent(const LogEvent& event) { } } - // For matched LogEntryMatchers, tell relevant metrics that a matched event has come. - for (size_t i = 0; i < mAllLogEntryMatchers.size(); i++) { + // For matched AtomMatchers, tell relevant metrics that a matched event has come. + for (size_t i = 0; i < mAllAtomMatchers.size(); i++) { if (matcherCache[i] == MatchingState::kMatched) { StatsdStats::getInstance().noteMatcherMatched(mConfigKey, - mAllLogEntryMatchers[i]->getName()); + mAllAtomMatchers[i]->getName()); auto pair = mTrackerToMetricMap.find(i); if (pair != mTrackerToMetricMap.end()) { auto& metricList = pair->second; diff --git a/cmds/statsd/src/metrics/MetricsManager.h b/cmds/statsd/src/metrics/MetricsManager.h index 62b4c872b318..4e6a0ce5439b 100644 --- a/cmds/statsd/src/metrics/MetricsManager.h +++ b/cmds/statsd/src/metrics/MetricsManager.h @@ -71,8 +71,8 @@ private: // holds A's sp. (2) When we evaluate matcher results, or condition results, we can quickly get // the related results from a cache using the index. - // Hold all the log entry matchers from the config. - std::vector<sp<LogMatchingTracker>> mAllLogEntryMatchers; + // Hold all the atom matchers from the config. + std::vector<sp<LogMatchingTracker>> mAllAtomMatchers; // Hold all the conditions from the config. std::vector<sp<ConditionTracker>> mAllConditionTrackers; diff --git a/cmds/statsd/src/metrics/metrics_manager_util.cpp b/cmds/statsd/src/metrics/metrics_manager_util.cpp index 33683f04cdd4..3fe710f51422 100644 --- a/cmds/statsd/src/metrics/metrics_manager_util.cpp +++ b/cmds/statsd/src/metrics/metrics_manager_util.cpp @@ -40,17 +40,17 @@ namespace statsd { bool handleMetricWithLogTrackers(const string what, const int metricIndex, const bool usedForDimension, - const vector<sp<LogMatchingTracker>>& allLogEntryMatchers, + const vector<sp<LogMatchingTracker>>& allAtomMatchers, const unordered_map<string, int>& logTrackerMap, unordered_map<int, std::vector<int>>& trackerToMetricMap, int& logTrackerIndex) { auto logTrackerIt = logTrackerMap.find(what); if (logTrackerIt == logTrackerMap.end()) { - ALOGW("cannot find the LogEntryMatcher \"%s\" in config", what.c_str()); + ALOGW("cannot find the AtomMatcher \"%s\" in config", what.c_str()); return false; } - if (usedForDimension && allLogEntryMatchers[logTrackerIt->second]->getTagIds().size() > 1) { - ALOGE("LogEntryMatcher \"%s\" has more than one tag ids. When a metric has dimension, " + if (usedForDimension && allAtomMatchers[logTrackerIt->second]->getTagIds().size() > 1) { + ALOGE("AtomMatcher \"%s\" has more than one tag ids. When a metric has dimension, " "the \"what\" can only about one atom type.", what.c_str()); return false; @@ -93,23 +93,23 @@ bool handleMetricWithConditions( } bool initLogTrackers(const StatsdConfig& config, unordered_map<string, int>& logTrackerMap, - vector<sp<LogMatchingTracker>>& allLogEntryMatchers, set<int>& allTagIds) { - vector<LogEntryMatcher> matcherConfigs; - const int logEntryMatcherCount = config.log_entry_matcher_size(); - matcherConfigs.reserve(logEntryMatcherCount); - allLogEntryMatchers.reserve(logEntryMatcherCount); + vector<sp<LogMatchingTracker>>& allAtomMatchers, set<int>& allTagIds) { + vector<AtomMatcher> matcherConfigs; + const int atomMatcherCount = config.atom_matcher_size(); + matcherConfigs.reserve(atomMatcherCount); + allAtomMatchers.reserve(atomMatcherCount); - for (int i = 0; i < logEntryMatcherCount; i++) { - const LogEntryMatcher& logMatcher = config.log_entry_matcher(i); + for (int i = 0; i < atomMatcherCount; i++) { + const AtomMatcher& logMatcher = config.atom_matcher(i); - int index = allLogEntryMatchers.size(); + int index = allAtomMatchers.size(); switch (logMatcher.contents_case()) { - case LogEntryMatcher::ContentsCase::kSimpleLogEntryMatcher: - allLogEntryMatchers.push_back(new SimpleLogMatchingTracker( - logMatcher.name(), index, logMatcher.simple_log_entry_matcher())); + case AtomMatcher::ContentsCase::kSimpleAtomMatcher: + allAtomMatchers.push_back(new SimpleLogMatchingTracker( + logMatcher.name(), index, logMatcher.simple_atom_matcher())); break; - case LogEntryMatcher::ContentsCase::kCombination: - allLogEntryMatchers.push_back( + case AtomMatcher::ContentsCase::kCombination: + allAtomMatchers.push_back( new CombinationLogMatchingTracker(logMatcher.name(), index)); break; default: @@ -118,16 +118,16 @@ bool initLogTrackers(const StatsdConfig& config, unordered_map<string, int>& log // continue; } if (logTrackerMap.find(logMatcher.name()) != logTrackerMap.end()) { - ALOGE("Duplicate LogEntryMatcher found!"); + ALOGE("Duplicate AtomMatcher found!"); return false; } logTrackerMap[logMatcher.name()] = index; matcherConfigs.push_back(logMatcher); } - vector<bool> stackTracker2(allLogEntryMatchers.size(), false); - for (auto& matcher : allLogEntryMatchers) { - if (!matcher->init(matcherConfigs, allLogEntryMatchers, logTrackerMap, stackTracker2)) { + vector<bool> stackTracker2(allAtomMatchers.size(), false); + for (auto& matcher : allAtomMatchers) { + if (!matcher->init(matcherConfigs, allAtomMatchers, logTrackerMap, stackTracker2)) { return false; } // Collect all the tag ids that are interesting. TagIds exist in leaf nodes only. @@ -191,7 +191,7 @@ bool initConditions(const ConfigKey& key, const StatsdConfig& config, bool initMetrics(const ConfigKey& key, const StatsdConfig& config, const unordered_map<string, int>& logTrackerMap, const unordered_map<string, int>& conditionTrackerMap, - const vector<sp<LogMatchingTracker>>& allLogEntryMatchers, + const vector<sp<LogMatchingTracker>>& allAtomMatchers, vector<sp<ConditionTracker>>& allConditionTrackers, vector<sp<MetricProducer>>& allMetricProducers, unordered_map<int, std::vector<int>>& conditionToMetricMap, @@ -217,7 +217,7 @@ bool initMetrics(const ConfigKey& key, const StatsdConfig& config, metricMap.insert({metric.name(), metricIndex}); int trackerIndex; if (!handleMetricWithLogTrackers(metric.what(), metricIndex, metric.dimension_size() > 0, - allLogEntryMatchers, logTrackerMap, trackerToMetricMap, + allAtomMatchers, logTrackerMap, trackerToMetricMap, trackerIndex)) { return false; } @@ -268,7 +268,7 @@ bool initMetrics(const ConfigKey& key, const StatsdConfig& config, int trackerIndices[3] = {-1, -1, -1}; if (!simpleCondition.has_start() || !handleMetricWithLogTrackers(simpleCondition.start(), metricIndex, - metric.dimension_size() > 0, allLogEntryMatchers, + metric.dimension_size() > 0, allAtomMatchers, logTrackerMap, trackerToMetricMap, trackerIndices[0])) { ALOGE("Duration metrics must specify a valid the start event matcher"); return false; @@ -276,14 +276,14 @@ bool initMetrics(const ConfigKey& key, const StatsdConfig& config, if (simpleCondition.has_stop() && !handleMetricWithLogTrackers(simpleCondition.stop(), metricIndex, - metric.dimension_size() > 0, allLogEntryMatchers, + metric.dimension_size() > 0, allAtomMatchers, logTrackerMap, trackerToMetricMap, trackerIndices[1])) { return false; } if (simpleCondition.has_stop_all() && !handleMetricWithLogTrackers(simpleCondition.stop_all(), metricIndex, - metric.dimension_size() > 0, allLogEntryMatchers, + metric.dimension_size() > 0, allAtomMatchers, logTrackerMap, trackerToMetricMap, trackerIndices[2])) { return false; } @@ -325,7 +325,7 @@ bool initMetrics(const ConfigKey& key, const StatsdConfig& config, return false; } int trackerIndex; - if (!handleMetricWithLogTrackers(metric.what(), metricIndex, false, allLogEntryMatchers, + if (!handleMetricWithLogTrackers(metric.what(), metricIndex, false, allAtomMatchers, logTrackerMap, trackerToMetricMap, trackerIndex)) { return false; } @@ -363,12 +363,12 @@ bool initMetrics(const ConfigKey& key, const StatsdConfig& config, metricMap.insert({metric.name(), metricIndex}); int trackerIndex; if (!handleMetricWithLogTrackers(metric.what(), metricIndex, metric.dimension_size() > 0, - allLogEntryMatchers, logTrackerMap, trackerToMetricMap, + allAtomMatchers, logTrackerMap, trackerToMetricMap, trackerIndex)) { return false; } - sp<LogMatchingTracker> atomMatcher = allLogEntryMatchers.at(trackerIndex); + sp<LogMatchingTracker> atomMatcher = allAtomMatchers.at(trackerIndex); // If it is pulled atom, it should be simple matcher with one tagId. int pullTagId = -1; for (int tagId : atomMatcher->getTagIds()) { @@ -412,12 +412,12 @@ bool initMetrics(const ConfigKey& key, const StatsdConfig& config, metricMap.insert({metric.name(), metricIndex}); int trackerIndex; if (!handleMetricWithLogTrackers(metric.what(), metricIndex, metric.dimension_size() > 0, - allLogEntryMatchers, logTrackerMap, trackerToMetricMap, + allAtomMatchers, logTrackerMap, trackerToMetricMap, trackerIndex)) { return false; } - sp<LogMatchingTracker> atomMatcher = allLogEntryMatchers.at(trackerIndex); + sp<LogMatchingTracker> atomMatcher = allAtomMatchers.at(trackerIndex); // If it is pulled atom, it should be simple matcher with one tagId. int pullTagId = -1; for (int tagId : atomMatcher->getTagIds()) { @@ -487,7 +487,7 @@ bool initAlerts(const StatsdConfig& config, const unordered_map<string, int>& me } bool initStatsdConfig(const ConfigKey& key, const StatsdConfig& config, set<int>& allTagIds, - vector<sp<LogMatchingTracker>>& allLogEntryMatchers, + vector<sp<LogMatchingTracker>>& allAtomMatchers, vector<sp<ConditionTracker>>& allConditionTrackers, vector<sp<MetricProducer>>& allMetricProducers, vector<sp<AnomalyTracker>>& allAnomalyTrackers, @@ -498,7 +498,7 @@ bool initStatsdConfig(const ConfigKey& key, const StatsdConfig& config, set<int> unordered_map<string, int> conditionTrackerMap; unordered_map<string, int> metricProducerMap; - if (!initLogTrackers(config, logTrackerMap, allLogEntryMatchers, allTagIds)) { + if (!initLogTrackers(config, logTrackerMap, allAtomMatchers, allTagIds)) { ALOGE("initLogMatchingTrackers failed"); return false; } @@ -510,7 +510,7 @@ bool initStatsdConfig(const ConfigKey& key, const StatsdConfig& config, set<int> return false; } - if (!initMetrics(key, config, logTrackerMap, conditionTrackerMap, allLogEntryMatchers, + if (!initMetrics(key, config, logTrackerMap, conditionTrackerMap, allAtomMatchers, allConditionTrackers, allMetricProducers, conditionToMetricMap, trackerToMetricMap, metricProducerMap)) { ALOGE("initMetricProducers failed"); diff --git a/cmds/statsd/src/metrics/metrics_manager_util.h b/cmds/statsd/src/metrics/metrics_manager_util.h index e7cbd533b5b4..751d8dff02f8 100644 --- a/cmds/statsd/src/metrics/metrics_manager_util.h +++ b/cmds/statsd/src/metrics/metrics_manager_util.h @@ -40,11 +40,11 @@ namespace statsd { // [config]: the input StatsdConfig // output: // [logTrackerMap]: this map should contain matcher name to index mapping -// [allLogEntryMatchers]: should store the sp to all the LogMatchingTracker +// [allAtomMatchers]: should store the sp to all the LogMatchingTracker // [allTagIds]: contains the set of all interesting tag ids to this config. bool initLogTrackers(const StatsdConfig& config, std::unordered_map<std::string, int>& logTrackerMap, - std::vector<sp<LogMatchingTracker>>& allLogEntryMatchers, + std::vector<sp<LogMatchingTracker>>& allAtomMatchers, std::set<int>& allTagIds); // Initialize ConditionTrackers @@ -80,7 +80,7 @@ bool initMetrics( const std::unordered_map<std::string, int>& logTrackerMap, const std::unordered_map<std::string, int>& conditionTrackerMap, const std::unordered_map<int, std::vector<EventConditionLink>>& eventConditionLinks, - const vector<sp<LogMatchingTracker>>& allLogEntryMatchers, + const vector<sp<LogMatchingTracker>>& allAtomMatchers, vector<sp<ConditionTracker>>& allConditionTrackers, std::vector<sp<MetricProducer>>& allMetricProducers, std::unordered_map<int, std::vector<int>>& conditionToMetricMap, @@ -89,7 +89,7 @@ bool initMetrics( // Initialize MetricsManager from StatsdConfig. // Parameters are the members of MetricsManager. See MetricsManager for declaration. bool initStatsdConfig(const ConfigKey& key, const StatsdConfig& config, std::set<int>& allTagIds, - std::vector<sp<LogMatchingTracker>>& allLogEntryMatchers, + std::vector<sp<LogMatchingTracker>>& allAtomMatchers, std::vector<sp<ConditionTracker>>& allConditionTrackers, std::vector<sp<MetricProducer>>& allMetricProducers, vector<sp<AnomalyTracker>>& allAnomalyTrackers, diff --git a/cmds/statsd/src/statsd_config.proto b/cmds/statsd/src/statsd_config.proto index c8fa155de569..6837be098b19 100644 --- a/cmds/statsd/src/statsd_config.proto +++ b/cmds/statsd/src/statsd_config.proto @@ -23,93 +23,93 @@ option java_package = "com.android.internal.os"; option java_outer_classname = "StatsdConfigProto"; message KeyMatcher { - optional int32 key = 1; + optional int32 key = 1; - optional bool as_package_name = 2 [ default = false ]; + optional bool as_package_name = 2 [default = false]; } message KeyValueMatcher { - optional KeyMatcher key_matcher = 1; + optional KeyMatcher key_matcher = 1; - oneof value_matcher { - bool eq_bool = 2; - string eq_string = 3; - int32 eq_int = 4; + oneof value_matcher { + bool eq_bool = 2; + string eq_string = 3; + int32 eq_int = 4; - int64 lt_int = 5; - int64 gt_int = 6; - float lt_float = 7; - float gt_float = 8; + int64 lt_int = 5; + int64 gt_int = 6; + float lt_float = 7; + float gt_float = 8; - int64 lte_int = 9; - int64 gte_int = 10; - } + int64 lte_int = 9; + int64 gte_int = 10; + } } enum LogicalOperation { - LOGICAL_OPERATION_UNSPECIFIED = 0; - AND = 1; - OR = 2; - NOT = 3; - NAND = 4; - NOR = 5; + LOGICAL_OPERATION_UNSPECIFIED = 0; + AND = 1; + OR = 2; + NOT = 3; + NAND = 4; + NOR = 5; } -message SimpleLogEntryMatcher { - optional int32 tag = 1; +message SimpleAtomMatcher { + optional int32 tag = 1; - repeated KeyValueMatcher key_value_matcher = 2; + repeated KeyValueMatcher key_value_matcher = 2; } -message LogEntryMatcher { - optional string name = 1; +message AtomMatcher { + optional string name = 1; - message Combination { - optional LogicalOperation operation = 1; + message Combination { + optional LogicalOperation operation = 1; - repeated string matcher = 2; - } - oneof contents { - SimpleLogEntryMatcher simple_log_entry_matcher = 2; - Combination combination = 3; - } + repeated string matcher = 2; + } + oneof contents { + SimpleAtomMatcher simple_atom_matcher = 2; + Combination combination = 3; + } } message SimpleCondition { - optional string start = 1; + optional string start = 1; - optional string stop = 2; + optional string stop = 2; - optional bool count_nesting = 3 [default = true]; + optional bool count_nesting = 3 [default = true]; - optional string stop_all = 4; + optional string stop_all = 4; - enum InitialValue { - UNKNOWN = 0; - FALSE = 1; - } - optional InitialValue initial_value = 5 [default = FALSE]; + enum InitialValue { + UNKNOWN = 0; + FALSE = 1; + } + optional InitialValue initial_value = 5 [default = FALSE]; - repeated KeyMatcher dimension = 6; + repeated KeyMatcher dimension = 6; } message Condition { - optional string name = 1; + optional string name = 1; - message Combination { - optional LogicalOperation operation = 1; + message Combination { + optional LogicalOperation operation = 1; - repeated string condition = 2; - } + repeated string condition = 2; + } - oneof contents { - SimpleCondition simple_condition = 2; - Combination combination = 3; - } + oneof contents { + SimpleCondition simple_condition = 2; + Combination combination = 3; + } } message Bucket { - optional int64 bucket_size_millis = 1; + optional int64 bucket_size_millis = 1; } message EventConditionLink { @@ -154,9 +154,9 @@ message DurationMetric { repeated EventConditionLink links = 4; enum AggregationType { - SUM = 1; + SUM = 1; - MAX_SPARSE = 2; + MAX_SPARSE = 2; } optional AggregationType aggregation_type = 5 [default = SUM]; @@ -196,9 +196,7 @@ message ValueMetric { repeated EventConditionLink links = 7; - enum AggregationType { - SUM = 1; - } + enum AggregationType { SUM = 1; } optional AggregationType aggregation_type = 8 [default = SUM]; } @@ -208,7 +206,7 @@ message Alert { optional string metric_name = 2; message IncidentdDetails { - repeated int32 section = 1; + repeated int32 section = 1; } optional IncidentdDetails incidentd_details = 3; @@ -232,7 +230,7 @@ message StatsdConfig { repeated DurationMetric duration_metric = 6; - repeated LogEntryMatcher log_entry_matcher = 7; + repeated AtomMatcher atom_matcher = 7; repeated Condition condition = 8; diff --git a/cmds/statsd/tests/LogEntryMatcher_test.cpp b/cmds/statsd/tests/LogEntryMatcher_test.cpp index 40c0e9d74c1d..1ec91558f790 100644 --- a/cmds/statsd/tests/LogEntryMatcher_test.cpp +++ b/cmds/statsd/tests/LogEntryMatcher_test.cpp @@ -36,10 +36,10 @@ const int FIELD_ID_3 = 2; extern "C" void android_log_rewind(android_log_context ctx); #ifdef __ANDROID__ -TEST(LogEntryMatcherTest, TestSimpleMatcher) { +TEST(AtomMatcherTest, TestSimpleMatcher) { // Set up the matcher - LogEntryMatcher matcher; - auto simpleMatcher = matcher.mutable_simple_log_entry_matcher(); + AtomMatcher matcher; + auto simpleMatcher = matcher.mutable_simple_atom_matcher(); simpleMatcher->set_tag(TAG_ID); LogEvent event(TAG_ID, 0); @@ -49,10 +49,10 @@ TEST(LogEntryMatcherTest, TestSimpleMatcher) { EXPECT_TRUE(matchesSimple(*simpleMatcher, event)); } -TEST(LogEntryMatcherTest, TestBoolMatcher) { +TEST(AtomMatcherTest, TestBoolMatcher) { // Set up the matcher - LogEntryMatcher matcher; - auto simpleMatcher = matcher.mutable_simple_log_entry_matcher(); + AtomMatcher matcher; + auto simpleMatcher = matcher.mutable_simple_atom_matcher(); simpleMatcher->set_tag(TAG_ID); auto keyValue1 = simpleMatcher->add_key_value_matcher(); keyValue1->mutable_key_matcher()->set_key(FIELD_ID_1); @@ -84,10 +84,10 @@ TEST(LogEntryMatcherTest, TestBoolMatcher) { EXPECT_FALSE(matchesSimple(*simpleMatcher, event)); } -TEST(LogEntryMatcherTest, TestStringMatcher) { +TEST(AtomMatcherTest, TestStringMatcher) { // Set up the matcher - LogEntryMatcher matcher; - auto simpleMatcher = matcher.mutable_simple_log_entry_matcher(); + AtomMatcher matcher; + auto simpleMatcher = matcher.mutable_simple_atom_matcher(); simpleMatcher->set_tag(TAG_ID); auto keyValue = simpleMatcher->add_key_value_matcher(); keyValue->mutable_key_matcher()->set_key(FIELD_ID_1); @@ -103,10 +103,10 @@ TEST(LogEntryMatcherTest, TestStringMatcher) { EXPECT_TRUE(matchesSimple(*simpleMatcher, event)); } -TEST(LogEntryMatcherTest, TestMultiFieldsMatcher) { +TEST(AtomMatcherTest, TestMultiFieldsMatcher) { // Set up the matcher - LogEntryMatcher matcher; - auto simpleMatcher = matcher.mutable_simple_log_entry_matcher(); + AtomMatcher matcher; + auto simpleMatcher = matcher.mutable_simple_atom_matcher(); simpleMatcher->set_tag(TAG_ID); auto keyValue1 = simpleMatcher->add_key_value_matcher(); keyValue1->mutable_key_matcher()->set_key(FIELD_ID_1); @@ -135,10 +135,10 @@ TEST(LogEntryMatcherTest, TestMultiFieldsMatcher) { EXPECT_FALSE(matchesSimple(*simpleMatcher, event)); } -TEST(LogEntryMatcherTest, TestIntComparisonMatcher) { +TEST(AtomMatcherTest, TestIntComparisonMatcher) { // Set up the matcher - LogEntryMatcher matcher; - auto simpleMatcher = matcher.mutable_simple_log_entry_matcher(); + AtomMatcher matcher; + auto simpleMatcher = matcher.mutable_simple_atom_matcher(); simpleMatcher->set_tag(TAG_ID); auto keyValue = simpleMatcher->add_key_value_matcher(); @@ -192,10 +192,10 @@ TEST(LogEntryMatcherTest, TestIntComparisonMatcher) { EXPECT_FALSE(matchesSimple(*simpleMatcher, event)); } -TEST(LogEntryMatcherTest, TestFloatComparisonMatcher) { +TEST(AtomMatcherTest, TestFloatComparisonMatcher) { // Set up the matcher - LogEntryMatcher matcher; - auto simpleMatcher = matcher.mutable_simple_log_entry_matcher(); + AtomMatcher matcher; + auto simpleMatcher = matcher.mutable_simple_atom_matcher(); simpleMatcher->set_tag(TAG_ID); auto keyValue = simpleMatcher->add_key_value_matcher(); @@ -225,14 +225,14 @@ TEST(LogEntryMatcherTest, TestFloatComparisonMatcher) { } // Helper for the composite matchers. -void addSimpleMatcher(SimpleLogEntryMatcher* simpleMatcher, int tag, int key, int val) { +void addSimpleMatcher(SimpleAtomMatcher* simpleMatcher, int tag, int key, int val) { simpleMatcher->set_tag(tag); auto keyValue = simpleMatcher->add_key_value_matcher(); keyValue->mutable_key_matcher()->set_key(key); keyValue->set_eq_int(val); } -TEST(LogEntryMatcherTest, TestAndMatcher) { +TEST(AtomMatcherTest, TestAndMatcher) { // Set up the matcher LogicalOperation operation = LogicalOperation::AND; @@ -256,7 +256,7 @@ TEST(LogEntryMatcherTest, TestAndMatcher) { EXPECT_TRUE(combinationMatch(children, operation, matcherResults)); } -TEST(LogEntryMatcherTest, TestOrMatcher) { +TEST(AtomMatcherTest, TestOrMatcher) { // Set up the matcher LogicalOperation operation = LogicalOperation::OR; @@ -280,7 +280,7 @@ TEST(LogEntryMatcherTest, TestOrMatcher) { EXPECT_FALSE(combinationMatch(children, operation, matcherResults)); } -TEST(LogEntryMatcherTest, TestNotMatcher) { +TEST(AtomMatcherTest, TestNotMatcher) { // Set up the matcher LogicalOperation operation = LogicalOperation::NOT; @@ -297,7 +297,7 @@ TEST(LogEntryMatcherTest, TestNotMatcher) { EXPECT_TRUE(combinationMatch(children, operation, matcherResults)); } -TEST(LogEntryMatcherTest, TestNandMatcher) { +TEST(AtomMatcherTest, TestNandMatcher) { // Set up the matcher LogicalOperation operation = LogicalOperation::NAND; @@ -322,7 +322,7 @@ TEST(LogEntryMatcherTest, TestNandMatcher) { EXPECT_FALSE(combinationMatch(children, operation, matcherResults)); } -TEST(LogEntryMatcherTest, TestNorMatcher) { +TEST(AtomMatcherTest, TestNorMatcher) { // Set up the matcher LogicalOperation operation = LogicalOperation::NOR; diff --git a/cmds/statsd/tests/MetricsManager_test.cpp b/cmds/statsd/tests/MetricsManager_test.cpp index 5384e0c2b9a9..e4750e9ccf36 100644 --- a/cmds/statsd/tests/MetricsManager_test.cpp +++ b/cmds/statsd/tests/MetricsManager_test.cpp @@ -46,30 +46,30 @@ StatsdConfig buildGoodConfig() { StatsdConfig config; config.set_name("12345"); - LogEntryMatcher* eventMatcher = config.add_log_entry_matcher(); + AtomMatcher* eventMatcher = config.add_atom_matcher(); eventMatcher->set_name("SCREEN_IS_ON"); - SimpleLogEntryMatcher* simpleLogEntryMatcher = eventMatcher->mutable_simple_log_entry_matcher(); - simpleLogEntryMatcher->set_tag(2 /*SCREEN_STATE_CHANGE*/); - simpleLogEntryMatcher->add_key_value_matcher()->mutable_key_matcher()->set_key( + SimpleAtomMatcher* simpleAtomMatcher = eventMatcher->mutable_simple_atom_matcher(); + simpleAtomMatcher->set_tag(2 /*SCREEN_STATE_CHANGE*/); + simpleAtomMatcher->add_key_value_matcher()->mutable_key_matcher()->set_key( 1 /*SCREEN_STATE_CHANGE__DISPLAY_STATE*/); - simpleLogEntryMatcher->mutable_key_value_matcher(0)->set_eq_int( + simpleAtomMatcher->mutable_key_value_matcher(0)->set_eq_int( 2 /*SCREEN_STATE_CHANGE__DISPLAY_STATE__STATE_ON*/); - eventMatcher = config.add_log_entry_matcher(); + eventMatcher = config.add_atom_matcher(); eventMatcher->set_name("SCREEN_IS_OFF"); - simpleLogEntryMatcher = eventMatcher->mutable_simple_log_entry_matcher(); - simpleLogEntryMatcher->set_tag(2 /*SCREEN_STATE_CHANGE*/); - simpleLogEntryMatcher->add_key_value_matcher()->mutable_key_matcher()->set_key( + simpleAtomMatcher = eventMatcher->mutable_simple_atom_matcher(); + simpleAtomMatcher->set_tag(2 /*SCREEN_STATE_CHANGE*/); + simpleAtomMatcher->add_key_value_matcher()->mutable_key_matcher()->set_key( 1 /*SCREEN_STATE_CHANGE__DISPLAY_STATE*/); - simpleLogEntryMatcher->mutable_key_value_matcher(0)->set_eq_int( + simpleAtomMatcher->mutable_key_value_matcher(0)->set_eq_int( 1 /*SCREEN_STATE_CHANGE__DISPLAY_STATE__STATE_OFF*/); - eventMatcher = config.add_log_entry_matcher(); + eventMatcher = config.add_atom_matcher(); eventMatcher->set_name("SCREEN_ON_OR_OFF"); - LogEntryMatcher_Combination* combination = eventMatcher->mutable_combination(); + AtomMatcher_Combination* combination = eventMatcher->mutable_combination(); combination->set_operation(LogicalOperation::OR); combination->add_matcher("SCREEN_IS_ON"); combination->add_matcher("SCREEN_IS_OFF"); @@ -94,20 +94,20 @@ StatsdConfig buildCircleMatchers() { StatsdConfig config; config.set_name("12345"); - LogEntryMatcher* eventMatcher = config.add_log_entry_matcher(); + AtomMatcher* eventMatcher = config.add_atom_matcher(); eventMatcher->set_name("SCREEN_IS_ON"); - SimpleLogEntryMatcher* simpleLogEntryMatcher = eventMatcher->mutable_simple_log_entry_matcher(); - simpleLogEntryMatcher->set_tag(2 /*SCREEN_STATE_CHANGE*/); - simpleLogEntryMatcher->add_key_value_matcher()->mutable_key_matcher()->set_key( + SimpleAtomMatcher* simpleAtomMatcher = eventMatcher->mutable_simple_atom_matcher(); + simpleAtomMatcher->set_tag(2 /*SCREEN_STATE_CHANGE*/); + simpleAtomMatcher->add_key_value_matcher()->mutable_key_matcher()->set_key( 1 /*SCREEN_STATE_CHANGE__DISPLAY_STATE*/); - simpleLogEntryMatcher->mutable_key_value_matcher(0)->set_eq_int( + simpleAtomMatcher->mutable_key_value_matcher(0)->set_eq_int( 2 /*SCREEN_STATE_CHANGE__DISPLAY_STATE__STATE_ON*/); - eventMatcher = config.add_log_entry_matcher(); + eventMatcher = config.add_atom_matcher(); eventMatcher->set_name("SCREEN_ON_OR_OFF"); - LogEntryMatcher_Combination* combination = eventMatcher->mutable_combination(); + AtomMatcher_Combination* combination = eventMatcher->mutable_combination(); combination->set_operation(LogicalOperation::OR); combination->add_matcher("SCREEN_IS_ON"); // Circle dependency @@ -120,7 +120,7 @@ StatsdConfig buildAlertWithUnknownMetric() { StatsdConfig config; config.set_name("12345"); - LogEntryMatcher* eventMatcher = config.add_log_entry_matcher(); + AtomMatcher* eventMatcher = config.add_atom_matcher(); eventMatcher->set_name("SCREEN_IS_ON"); CountMetric* metric = config.add_count_metric(); @@ -143,20 +143,20 @@ StatsdConfig buildMissingMatchers() { StatsdConfig config; config.set_name("12345"); - LogEntryMatcher* eventMatcher = config.add_log_entry_matcher(); + AtomMatcher* eventMatcher = config.add_atom_matcher(); eventMatcher->set_name("SCREEN_IS_ON"); - SimpleLogEntryMatcher* simpleLogEntryMatcher = eventMatcher->mutable_simple_log_entry_matcher(); - simpleLogEntryMatcher->set_tag(2 /*SCREEN_STATE_CHANGE*/); - simpleLogEntryMatcher->add_key_value_matcher()->mutable_key_matcher()->set_key( + SimpleAtomMatcher* simpleAtomMatcher = eventMatcher->mutable_simple_atom_matcher(); + simpleAtomMatcher->set_tag(2 /*SCREEN_STATE_CHANGE*/); + simpleAtomMatcher->add_key_value_matcher()->mutable_key_matcher()->set_key( 1 /*SCREEN_STATE_CHANGE__DISPLAY_STATE*/); - simpleLogEntryMatcher->mutable_key_value_matcher(0)->set_eq_int( + simpleAtomMatcher->mutable_key_value_matcher(0)->set_eq_int( 2 /*SCREEN_STATE_CHANGE__DISPLAY_STATE__STATE_ON*/); - eventMatcher = config.add_log_entry_matcher(); + eventMatcher = config.add_atom_matcher(); eventMatcher->set_name("SCREEN_ON_OR_OFF"); - LogEntryMatcher_Combination* combination = eventMatcher->mutable_combination(); + AtomMatcher_Combination* combination = eventMatcher->mutable_combination(); combination->set_operation(LogicalOperation::OR); combination->add_matcher("SCREEN_IS_ON"); // undefined matcher @@ -175,11 +175,11 @@ StatsdConfig buildMissingCondition() { metric->mutable_bucket()->set_bucket_size_millis(30 * 1000L); metric->set_condition("SOME_CONDITION"); - LogEntryMatcher* eventMatcher = config.add_log_entry_matcher(); + AtomMatcher* eventMatcher = config.add_atom_matcher(); eventMatcher->set_name("SCREEN_EVENT"); - SimpleLogEntryMatcher* simpleLogEntryMatcher = eventMatcher->mutable_simple_log_entry_matcher(); - simpleLogEntryMatcher->set_tag(2); + SimpleAtomMatcher* simpleAtomMatcher = eventMatcher->mutable_simple_atom_matcher(); + simpleAtomMatcher->set_tag(2); return config; } @@ -188,20 +188,20 @@ StatsdConfig buildDimensionMetricsWithMultiTags() { StatsdConfig config; config.set_name("12345"); - LogEntryMatcher* eventMatcher = config.add_log_entry_matcher(); + AtomMatcher* eventMatcher = config.add_atom_matcher(); eventMatcher->set_name("BATTERY_VERY_LOW"); - SimpleLogEntryMatcher* simpleLogEntryMatcher = eventMatcher->mutable_simple_log_entry_matcher(); - simpleLogEntryMatcher->set_tag(2); + SimpleAtomMatcher* simpleAtomMatcher = eventMatcher->mutable_simple_atom_matcher(); + simpleAtomMatcher->set_tag(2); - eventMatcher = config.add_log_entry_matcher(); + eventMatcher = config.add_atom_matcher(); eventMatcher->set_name("BATTERY_VERY_VERY_LOW"); - simpleLogEntryMatcher = eventMatcher->mutable_simple_log_entry_matcher(); - simpleLogEntryMatcher->set_tag(3); + simpleAtomMatcher = eventMatcher->mutable_simple_atom_matcher(); + simpleAtomMatcher->set_tag(3); - eventMatcher = config.add_log_entry_matcher(); + eventMatcher = config.add_atom_matcher(); eventMatcher->set_name("BATTERY_LOW"); - LogEntryMatcher_Combination* combination = eventMatcher->mutable_combination(); + AtomMatcher_Combination* combination = eventMatcher->mutable_combination(); combination->set_operation(LogicalOperation::OR); combination->add_matcher("BATTERY_VERY_LOW"); combination->add_matcher("BATTERY_VERY_VERY_LOW"); @@ -227,24 +227,24 @@ StatsdConfig buildCircleConditions() { StatsdConfig config; config.set_name("12345"); - LogEntryMatcher* eventMatcher = config.add_log_entry_matcher(); + AtomMatcher* eventMatcher = config.add_atom_matcher(); eventMatcher->set_name("SCREEN_IS_ON"); - SimpleLogEntryMatcher* simpleLogEntryMatcher = eventMatcher->mutable_simple_log_entry_matcher(); - simpleLogEntryMatcher->set_tag(2 /*SCREEN_STATE_CHANGE*/); - simpleLogEntryMatcher->add_key_value_matcher()->mutable_key_matcher()->set_key( + SimpleAtomMatcher* simpleAtomMatcher = eventMatcher->mutable_simple_atom_matcher(); + simpleAtomMatcher->set_tag(2 /*SCREEN_STATE_CHANGE*/); + simpleAtomMatcher->add_key_value_matcher()->mutable_key_matcher()->set_key( 1 /*SCREEN_STATE_CHANGE__DISPLAY_STATE*/); - simpleLogEntryMatcher->mutable_key_value_matcher(0)->set_eq_int( + simpleAtomMatcher->mutable_key_value_matcher(0)->set_eq_int( 2 /*SCREEN_STATE_CHANGE__DISPLAY_STATE__STATE_ON*/); - eventMatcher = config.add_log_entry_matcher(); + eventMatcher = config.add_atom_matcher(); eventMatcher->set_name("SCREEN_IS_OFF"); - simpleLogEntryMatcher = eventMatcher->mutable_simple_log_entry_matcher(); - simpleLogEntryMatcher->set_tag(2 /*SCREEN_STATE_CHANGE*/); - simpleLogEntryMatcher->add_key_value_matcher()->mutable_key_matcher()->set_key( + simpleAtomMatcher = eventMatcher->mutable_simple_atom_matcher(); + simpleAtomMatcher->set_tag(2 /*SCREEN_STATE_CHANGE*/); + simpleAtomMatcher->add_key_value_matcher()->mutable_key_matcher()->set_key( 1 /*SCREEN_STATE_CHANGE__DISPLAY_STATE*/); - simpleLogEntryMatcher->mutable_key_value_matcher(0)->set_eq_int( + simpleAtomMatcher->mutable_key_value_matcher(0)->set_eq_int( 1 /*SCREEN_STATE_CHANGE__DISPLAY_STATE__STATE_OFF*/); auto condition = config.add_condition(); @@ -267,7 +267,7 @@ StatsdConfig buildCircleConditions() { TEST(MetricsManagerTest, TestGoodConfig) { StatsdConfig config = buildGoodConfig(); set<int> allTagIds; - vector<sp<LogMatchingTracker>> allLogEntryMatchers; + vector<sp<LogMatchingTracker>> allAtomMatchers; vector<sp<ConditionTracker>> allConditionTrackers; vector<sp<MetricProducer>> allMetricProducers; std::vector<sp<AnomalyTracker>> allAnomalyTrackers; @@ -275,7 +275,7 @@ TEST(MetricsManagerTest, TestGoodConfig) { unordered_map<int, std::vector<int>> trackerToMetricMap; unordered_map<int, std::vector<int>> trackerToConditionMap; - EXPECT_TRUE(initStatsdConfig(kConfigKey, config, allTagIds, allLogEntryMatchers, + EXPECT_TRUE(initStatsdConfig(kConfigKey, config, allTagIds, allAtomMatchers, allConditionTrackers, allMetricProducers, allAnomalyTrackers, conditionToMetricMap, trackerToMetricMap, trackerToConditionMap)); EXPECT_EQ(1u, allMetricProducers.size()); @@ -285,7 +285,7 @@ TEST(MetricsManagerTest, TestGoodConfig) { TEST(MetricsManagerTest, TestDimensionMetricsWithMultiTags) { StatsdConfig config = buildDimensionMetricsWithMultiTags(); set<int> allTagIds; - vector<sp<LogMatchingTracker>> allLogEntryMatchers; + vector<sp<LogMatchingTracker>> allAtomMatchers; vector<sp<ConditionTracker>> allConditionTrackers; vector<sp<MetricProducer>> allMetricProducers; std::vector<sp<AnomalyTracker>> allAnomalyTrackers; @@ -293,7 +293,7 @@ TEST(MetricsManagerTest, TestDimensionMetricsWithMultiTags) { unordered_map<int, std::vector<int>> trackerToMetricMap; unordered_map<int, std::vector<int>> trackerToConditionMap; - EXPECT_FALSE(initStatsdConfig(kConfigKey, config, allTagIds, allLogEntryMatchers, + EXPECT_FALSE(initStatsdConfig(kConfigKey, config, allTagIds, allAtomMatchers, allConditionTrackers, allMetricProducers, allAnomalyTrackers, conditionToMetricMap, trackerToMetricMap, trackerToConditionMap)); } @@ -301,7 +301,7 @@ TEST(MetricsManagerTest, TestDimensionMetricsWithMultiTags) { TEST(MetricsManagerTest, TestCircleLogMatcherDependency) { StatsdConfig config = buildCircleMatchers(); set<int> allTagIds; - vector<sp<LogMatchingTracker>> allLogEntryMatchers; + vector<sp<LogMatchingTracker>> allAtomMatchers; vector<sp<ConditionTracker>> allConditionTrackers; vector<sp<MetricProducer>> allMetricProducers; std::vector<sp<AnomalyTracker>> allAnomalyTrackers; @@ -309,7 +309,7 @@ TEST(MetricsManagerTest, TestCircleLogMatcherDependency) { unordered_map<int, std::vector<int>> trackerToMetricMap; unordered_map<int, std::vector<int>> trackerToConditionMap; - EXPECT_FALSE(initStatsdConfig(kConfigKey, config, allTagIds, allLogEntryMatchers, + EXPECT_FALSE(initStatsdConfig(kConfigKey, config, allTagIds, allAtomMatchers, allConditionTrackers, allMetricProducers, allAnomalyTrackers, conditionToMetricMap, trackerToMetricMap, trackerToConditionMap)); } @@ -317,14 +317,14 @@ TEST(MetricsManagerTest, TestCircleLogMatcherDependency) { TEST(MetricsManagerTest, TestMissingMatchers) { StatsdConfig config = buildMissingMatchers(); set<int> allTagIds; - vector<sp<LogMatchingTracker>> allLogEntryMatchers; + vector<sp<LogMatchingTracker>> allAtomMatchers; vector<sp<ConditionTracker>> allConditionTrackers; vector<sp<MetricProducer>> allMetricProducers; std::vector<sp<AnomalyTracker>> allAnomalyTrackers; unordered_map<int, std::vector<int>> conditionToMetricMap; unordered_map<int, std::vector<int>> trackerToMetricMap; unordered_map<int, std::vector<int>> trackerToConditionMap; - EXPECT_FALSE(initStatsdConfig(kConfigKey, config, allTagIds, allLogEntryMatchers, + EXPECT_FALSE(initStatsdConfig(kConfigKey, config, allTagIds, allAtomMatchers, allConditionTrackers, allMetricProducers, allAnomalyTrackers, conditionToMetricMap, trackerToMetricMap, trackerToConditionMap)); } @@ -332,14 +332,14 @@ TEST(MetricsManagerTest, TestMissingMatchers) { TEST(MetricsManagerTest, TestMissingCondition) { StatsdConfig config = buildMissingCondition(); set<int> allTagIds; - vector<sp<LogMatchingTracker>> allLogEntryMatchers; + vector<sp<LogMatchingTracker>> allAtomMatchers; vector<sp<ConditionTracker>> allConditionTrackers; vector<sp<MetricProducer>> allMetricProducers; std::vector<sp<AnomalyTracker>> allAnomalyTrackers; unordered_map<int, std::vector<int>> conditionToMetricMap; unordered_map<int, std::vector<int>> trackerToMetricMap; unordered_map<int, std::vector<int>> trackerToConditionMap; - EXPECT_FALSE(initStatsdConfig(kConfigKey, config, allTagIds, allLogEntryMatchers, + EXPECT_FALSE(initStatsdConfig(kConfigKey, config, allTagIds, allAtomMatchers, allConditionTrackers, allMetricProducers, allAnomalyTrackers, conditionToMetricMap, trackerToMetricMap, trackerToConditionMap)); } @@ -347,7 +347,7 @@ TEST(MetricsManagerTest, TestMissingCondition) { TEST(MetricsManagerTest, TestCircleConditionDependency) { StatsdConfig config = buildCircleConditions(); set<int> allTagIds; - vector<sp<LogMatchingTracker>> allLogEntryMatchers; + vector<sp<LogMatchingTracker>> allAtomMatchers; vector<sp<ConditionTracker>> allConditionTrackers; vector<sp<MetricProducer>> allMetricProducers; std::vector<sp<AnomalyTracker>> allAnomalyTrackers; @@ -355,7 +355,7 @@ TEST(MetricsManagerTest, TestCircleConditionDependency) { unordered_map<int, std::vector<int>> trackerToMetricMap; unordered_map<int, std::vector<int>> trackerToConditionMap; - EXPECT_FALSE(initStatsdConfig(kConfigKey, config, allTagIds, allLogEntryMatchers, + EXPECT_FALSE(initStatsdConfig(kConfigKey, config, allTagIds, allAtomMatchers, allConditionTrackers, allMetricProducers, allAnomalyTrackers, conditionToMetricMap, trackerToMetricMap, trackerToConditionMap)); } @@ -363,7 +363,7 @@ TEST(MetricsManagerTest, TestCircleConditionDependency) { TEST(MetricsManagerTest, testAlertWithUnknownMetric) { StatsdConfig config = buildAlertWithUnknownMetric(); set<int> allTagIds; - vector<sp<LogMatchingTracker>> allLogEntryMatchers; + vector<sp<LogMatchingTracker>> allAtomMatchers; vector<sp<ConditionTracker>> allConditionTrackers; vector<sp<MetricProducer>> allMetricProducers; std::vector<sp<AnomalyTracker>> allAnomalyTrackers; @@ -371,7 +371,7 @@ TEST(MetricsManagerTest, testAlertWithUnknownMetric) { unordered_map<int, std::vector<int>> trackerToMetricMap; unordered_map<int, std::vector<int>> trackerToConditionMap; - EXPECT_FALSE(initStatsdConfig(kConfigKey, config, allTagIds, allLogEntryMatchers, + EXPECT_FALSE(initStatsdConfig(kConfigKey, config, allTagIds, allAtomMatchers, allConditionTrackers, allMetricProducers, allAnomalyTrackers, conditionToMetricMap, trackerToMetricMap, trackerToConditionMap)); } 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 7ecc124e5426..e7bb539e8b75 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 @@ -30,9 +30,8 @@ import com.android.internal.os.StatsdConfigProto.GaugeMetric; import com.android.internal.os.StatsdConfigProto.ValueMetric; import com.android.internal.os.StatsdConfigProto.KeyMatcher; import com.android.internal.os.StatsdConfigProto.KeyValueMatcher; -import com.android.internal.os.StatsdConfigProto.LogEntryMatcher; +import com.android.internal.os.StatsdConfigProto.AtomMatcher; import com.android.internal.os.StatsdConfigProto.SimpleCondition; -import com.android.internal.os.StatsdConfigProto.SimpleLogEntryMatcher; import com.android.internal.os.StatsdConfigProto.StatsdConfig; import java.io.InputStream; @@ -119,7 +118,7 @@ public class ConfigFactory { addCondition(condition, i, config); } // matchers - for (LogEntryMatcher matcher : mTemplate.getLogEntryMatcherList()) { + for (AtomMatcher matcher : mTemplate.getAtomMatcherList()) { addMatcher(matcher, i, config); } } @@ -282,20 +281,20 @@ public class ConfigFactory { } /** - * Creates a {@link LogEntryMatcher} based on the template. Makes sure that all names + * Creates a {@link AtomMatcher} based on the template. Makes sure that all names * are appended with the provided suffix. Then adds that matcher to the config. */ - private void addMatcher(LogEntryMatcher template, int suffix, StatsdConfig.Builder config) { - LogEntryMatcher.Builder matcher = template.toBuilder() + private void addMatcher(AtomMatcher template, int suffix, StatsdConfig.Builder config) { + AtomMatcher.Builder matcher = template.toBuilder() .setName(template.getName() + suffix); if (template.hasCombination()) { - LogEntryMatcher.Combination.Builder cb = template.getCombination().toBuilder() + AtomMatcher.Combination.Builder cb = template.getCombination().toBuilder() .clearMatcher(); for (String child : template.getCombination().getMatcherList()) { cb.addMatcher(child + suffix); } matcher.setCombination(cb); } - config.addLogEntryMatcher(matcher); + config.addAtomMatcher(matcher); } } |