// Copyright 2023 Google LLC
//
// 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 = "proto3";

package stats;

import "api/log/log.proto";
import "api/stat/stat.proto";

option go_package = "github.com/bazelbuild/reclient/api/stats";

// The full aggregated build stats and properties.
message Stats {
  // Number of actions in the build.
  int64 num_records = 1;

  // Aggregated build stats.
  repeated Stat stats = 2;

  // Verification results, if exist.
  log.Verification verification = 4;

  // RBE tooling version.
  string tool_version = 5;

  // Unique invocation IDs of the aggregated actions.
  repeated string invocation_ids = 6;

  // Information about the build machine.
  MachineInfo machine_info = 7;

  // Information relative to each reproxy invocation.
  repeated log.ProxyInfo proxy_info = 9;

  // The number of cache hits divided by the number of actions. 0 if there are
  // no actions.
  double build_cache_hit_ratio = 10;

  // Total seconds between start of first build action and end of last build
  // action. 0 if there are no actions.
  double build_latency = 11;

  // Whether FATAL log files were found in the log directory when reproxy was
  // shutdown by bootstrap.
  bool fatal_exit = 12;

  // The log directories that are uploaded to CAS.
  repeated LogDirectory log_directories = 13;

  reserved 3, 8;
}

message LogDirectory {
  // Absolute path of directory
  string path = 1;
  // CAS digest of directory
  string digest = 2;
}

message MachineInfo {
  // Number of CPU cores that the machine has.
  int64 num_cpu = 1;

  // Amount of RAM that the machine has in megabytes.
  int64 ram_mbs = 2;

  // Type of operating system of the build machine.
  string os_family = 3;

  // The architecture of the machine's CPU.
  string arch = 4;
}
