diff options
| -rw-r--r-- | cmds/statsd/src/anomaly/AnomalyTracker.cpp | 10 | ||||
| -rw-r--r-- | cmds/statsd/src/statsd_config.proto | 2 |
2 files changed, 11 insertions, 1 deletions
diff --git a/cmds/statsd/src/anomaly/AnomalyTracker.cpp b/cmds/statsd/src/anomaly/AnomalyTracker.cpp index 443d33d39915..22d775a3b4bb 100644 --- a/cmds/statsd/src/anomaly/AnomalyTracker.cpp +++ b/cmds/statsd/src/anomaly/AnomalyTracker.cpp @@ -229,11 +229,19 @@ bool AnomalyTracker::isInRefractoryPeriod(const uint64_t& timestampNs, void AnomalyTracker::informSubscribers(const MetricDimensionKey& key) { VLOG("informSubscribers called."); if (mSubscriptions.empty()) { - ALOGE("Attempt to call with no subscribers."); + // The config just wanted to log the anomaly. That's fine. + VLOG("No Subscriptions were associated with the alert."); return; } for (const Subscription& subscription : mSubscriptions) { + if (subscription.probability_of_informing() < 1 + && ((float)rand() / RAND_MAX) >= subscription.probability_of_informing()) { + // Note that due to float imprecision, 0.0 and 1.0 might not truly mean never/always. + // The config writer was advised to use -0.1 and 1.1 for never/always. + ALOGI("Fate decided that a subscriber would not be informed."); + continue; + } switch (subscription.subscriber_information_case()) { case Subscription::SubscriberInformationCase::kIncidentdDetails: if (!GenerateIncidentReport(subscription.incidentd_details(), mAlert, mConfigKey)) { diff --git a/cmds/statsd/src/statsd_config.proto b/cmds/statsd/src/statsd_config.proto index 5a326a47eb24..a19df75c5e92 100644 --- a/cmds/statsd/src/statsd_config.proto +++ b/cmds/statsd/src/statsd_config.proto @@ -308,6 +308,8 @@ message Subscription { PerfettoDetails perfetto_details = 5; BroadcastSubscriberDetails broadcast_subscriber_details = 6; } + + optional float probability_of_informing = 7 [default = 1.1]; } message StatsdConfig { |