/*
 * Copyright (C) 2024 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

syntax = "proto2";

package perfetto.protos;

// Detects outlier scenarios in different Android Systems in a trace. For now,
// this just detects high binder transaction rates. In the future, there could
// be others like garbage_collection, CPU, broadcasts, etc.
message AndroidAnomalyMetric {
  enum Unit {
    UNIT_UNSPECIFIED = 0;
    COUNT_PER_SECOND = 1;
  }

  // For anomalies related to a particular process.
  message ProcessAnomaly {
    optional string process_name = 1;
    optional uint32 pid = 2;
    optional Unit unit = 3;
    optional uint32 value = 4;
  }

  // Binder subsystem outliers with the following aggegations:
  // 1. Max incoming binder transaction count from each process over a one
  // second sliding window.
  // 2. Max outgoing binder transaction count from each process over a one
  // second sliding window.
  message Binder {
    repeated ProcessAnomaly max_incoming_process_count_per_second = 1;
    repeated ProcessAnomaly max_outgoing_process_count_per_second = 2;
  }

  optional Binder binder = 1;
}
