syntax = "proto3";
package event;

import "google/protobuf/timestamp.proto";

message EventWrapper {
  oneof event {
    Log log = 1;
    Metric metric = 2;
  }
}

message Log {
  map<string, Value> fields = 1;
}

message ValueMap {
  map<string, Value> fields = 1;
}

message ValueArray {
  repeated Value items = 1;
}

enum ValueNull {
  NULL_VALUE = 0;
}

message Value {
  reserved 3;
  oneof kind {
    bytes raw_bytes = 1;
    google.protobuf.Timestamp timestamp = 2;
    int64 integer = 4;
    double float = 5;
    bool boolean = 6;
    ValueMap map = 7;
    ValueArray array = 8;
    ValueNull null = 9;
  }
}

message Metric {
  string name = 1;
  google.protobuf.Timestamp timestamp = 2;
  map<string, string> tags = 3;
  enum Kind {
    Incremental = 0;
    Absolute = 1;
  }
  Kind kind = 4;
  oneof value {
    Counter counter = 5;
    Gauge gauge = 6;
    Set set = 7;
    Distribution1 distribution1 = 8;
    AggregatedHistogram1 aggregated_histogram1 = 9;
    AggregatedSummary1 aggregated_summary1 = 10;
    Distribution2 distribution2 = 12;
    AggregatedHistogram2 aggregated_histogram2 = 13;
    AggregatedSummary2 aggregated_summary2 = 14;
  }
  string namespace = 11;
}

message Counter {
  double value = 1;
}

message Gauge {
  double value = 1;
}

message Set {
  repeated string values = 1;
}

enum StatisticKind {
  Histogram = 0;
  Summary = 1;
}

message Distribution1 {
  repeated double values = 1;
  repeated uint32 sample_rates = 2;
  StatisticKind statistic = 3;
}

message Distribution2 {
  repeated DistributionSample samples = 1;
  StatisticKind statistic = 2;
}

message DistributionSample {
  double value = 1;
  uint32 rate = 2;
}

message AggregatedHistogram1 {
  repeated double buckets = 1;
  repeated uint32 counts = 2;
  uint32 count = 3;
  double sum = 4;
}

message AggregatedHistogram2 {
  repeated HistogramBucket buckets = 1;
  uint32 count = 2;
  double sum = 3;
}

message HistogramBucket {
  double upper_limit = 1;
  uint32 count = 2;
}

message AggregatedSummary1 {
  repeated double quantiles = 1;
  repeated double values = 2;
  uint32 count = 3;
  double sum = 4;
}

message AggregatedSummary2 {
  repeated SummaryQuantile quantiles = 1;
  uint32 count = 2;
  double sum = 3;
}

message SummaryQuantile {
  double upper_limit = 1;
  double value = 2;
}
