summaryrefslogtreecommitdiff
path: root/cmds/statsd/src/metrics/MetricsManager.cpp
diff options
context:
space:
mode:
authorTej Singh <singhtejinder@google.com>2020-10-27 20:56:11 -0700
committerTej Singh <singhtejinder@google.com>2020-11-02 02:01:00 -0800
commitd07d0ff02f62627f1831acd05f3e153b607858f7 (patch)
tree25a601f4bbd152743c7784c2e30f3a38ba5e01fc /cmds/statsd/src/metrics/MetricsManager.cpp
parentc44ef9e2536f69a902049cabc15f52daa2fa9ae7 (diff)
Partial config update for alerts/subscriptions
Preserves alerts if the definition didn't change and the underlying metric didnt change. All alerts need to be readded to the metric b/c metrics will always clear the alerts on config updates. In the existing code, the metric producer created the AnomalyTracker (since duration metrics need DurationAnomalyTrackers). Preserved alerts already have an AnomalyTracker. Therefore, we need a second overload of addAnomalyTracker within MetricProducer to add existing ones. Note that we don't need to worry about the type of AnomlayTracker, since if the alert is preserved, both the AnomalyTracker and metric must not have changed, so they will both be the correct type. Subscriptions are also redone - alerts will clear their subscriptions, and all subscriptions will be readded. For duration metric, we now need to propagate adding anomaly trackers to the DurationTrackers since it's now possible to add anomaly trackers after the durationTrackers have been created. Test: atest statsd_test Bug: 162323547 Change-Id: Id3afa04b252f3a3523114407a389be25b9171a97
Diffstat (limited to 'cmds/statsd/src/metrics/MetricsManager.cpp')
-rw-r--r--cmds/statsd/src/metrics/MetricsManager.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/cmds/statsd/src/metrics/MetricsManager.cpp b/cmds/statsd/src/metrics/MetricsManager.cpp
index ab0d286d6b29..b1d439703709 100644
--- a/cmds/statsd/src/metrics/MetricsManager.cpp
+++ b/cmds/statsd/src/metrics/MetricsManager.cpp
@@ -209,6 +209,8 @@ bool MetricsManager::updateConfig(const StatsdConfig& config, const int64_t time
map<int64_t, uint64_t> newStateProtoHashes;
vector<sp<MetricProducer>> newMetricProducers;
unordered_map<int64_t, int> newMetricProducerMap;
+ vector<sp<AnomalyTracker>> newAnomalyTrackers;
+ unordered_map<int64_t, int> newAlertTrackerMap;
mTagIds.clear();
mConditionToMetricMap.clear();
mTrackerToMetricMap.clear();
@@ -221,9 +223,10 @@ bool MetricsManager::updateConfig(const StatsdConfig& config, const int64_t time
mConfigKey, config, mUidMap, mPullerManager, anomalyAlarmMonitor, periodicAlarmMonitor,
timeBaseNs, currentTimeNs, mAllAtomMatchingTrackers, mAtomMatchingTrackerMap,
mAllConditionTrackers, mConditionTrackerMap, mAllMetricProducers, mMetricProducerMap,
- mStateProtoHashes, mTagIds, newAtomMatchingTrackers, newAtomMatchingTrackerMap,
- newConditionTrackers, newConditionTrackerMap, newMetricProducers, newMetricProducerMap,
- mConditionToMetricMap, mTrackerToMetricMap, mTrackerToConditionMap,
+ mAllAnomalyTrackers, mAlertTrackerMap, mStateProtoHashes, mTagIds,
+ newAtomMatchingTrackers, newAtomMatchingTrackerMap, newConditionTrackers,
+ newConditionTrackerMap, newMetricProducers, newMetricProducerMap, newAnomalyTrackers,
+ newAlertTrackerMap, mConditionToMetricMap, mTrackerToMetricMap, mTrackerToConditionMap,
mActivationAtomTrackerToMetricMap, mDeactivationAtomTrackerToMetricMap,
mMetricIndexesWithActivation, newStateProtoHashes, mNoReportMetricIds);
mAllAtomMatchingTrackers = newAtomMatchingTrackers;
@@ -233,6 +236,8 @@ bool MetricsManager::updateConfig(const StatsdConfig& config, const int64_t time
mAllMetricProducers = newMetricProducers;
mMetricProducerMap = newMetricProducerMap;
mStateProtoHashes = newStateProtoHashes;
+ mAllAnomalyTrackers = newAnomalyTrackers;
+ mAlertTrackerMap = newAlertTrackerMap;
return mConfigValid;
}