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

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

Merge "Statsd alerts can inform subscribers probabilistically"

parents e406ac08 12c1270f
Loading
Loading
Loading
Loading
+9 −1
Original line number Diff line number Diff line
@@ -233,11 +233,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)) {
+2 −0
Original line number Diff line number Diff line
@@ -307,6 +307,8 @@ message Subscription {
    PerfettoDetails perfetto_details = 5;
    BroadcastSubscriberDetails broadcast_subscriber_details = 6;
  }

  optional float probability_of_informing = 7 [default = 1.1];
}

message StatsdConfig {