// Copyright 2022 The TensorStore Authors
//
// 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 tensorstore.metrics_proto;

message IntCounter {
  int64 value = 1;
}

message DoubleCounter {
  double value = 1;
}

message IntGauge {
  int64 value = 1;
  int64 max_value = 2;
}

message DoubleGauge {
  double value = 1;
  double max_value = 2;
}

message IntValue {
  int64 value = 1;
}

message DoubleValue {
  double value = 1;
}

message StringValue {
  string value = 1;
}

message Histogram {
  int64 count = 1;
  double sum = 2;
  repeated int64 bucket = 3 [packed = true];
}

message MetricInstance {
  repeated string field = 1;

  oneof kind {
    IntCounter int_counter = 2;
    DoubleCounter double_counter = 3;

    IntGauge int_gauge = 4;
    DoubleGauge double_gauge = 5;

    IntValue int_value = 6;
    DoubleValue double_value = 7;
    StringValue string_value = 8;

    Histogram histogram = 9;
  }
}

message Metadata {
  string description = 1;
}

message Metric {
  string metric_name = 1;
  string tag = 2;
  repeated string field_name = 3;
  Metadata metadata = 4;

  repeated MetricInstance instance = 5;
}

message MetricCollection {
  repeated Metric metric = 1;
}
