enum AggType { Gauge Sum Histogram ExponentialHistogram Summary } # Defines a Metric which has one or more timeseries # # The data model and relation between entities is shown in the # diagram below. Here, "DataPoint" is the term used to refer to any # one of the specific data point value types, and "points" is the term used # to refer to any one of the lists of points contained in the Metric. # # - Metric is composed of a metadata and data. # - Metadata part contains a name, description, unit. # - Data is one of the possible types (Sum, Gauge, Histogram, Summary). # - DataPoint contains timestamps, attributes, and one of the possible value type # fields. # # Metric # +------------+ # |name | # |description | # |unit | +------------------------------------+ # |data |---> |Gauge, Sum, Histogram, Summary, ... | # +------------+ +------------------------------------+ # # Data [One of Gauge, Sum, Histogram, Summary, ...] # +-----------+ # |... | // Metadata about the Data. # |points |--+ # +-----------+ | # | +---------------------------+ # | |DataPoint 1 | # v |+------+------+ +------+ | # +-----+ ||label |label |...|label | | # | 1 |-->||value1|value2|...|valueN| | # +-----+ |+------+------+ +------+ | # | . | |+-----+ | # | . | ||value| | # | . | |+-----+ | # | . | +---------------------------+ # | . | . # | . | . # | . | . # | . | +---------------------------+ # | . | |DataPoint M | # +-----+ |+------+------+ +------+ | # | M |-->||label |label |...|label | | # +-----+ ||value1|value2|...|valueN| | # |+------+------+ +------+ | # |+-----+ | # ||value| | # |+-----+ | # +---------------------------+ # # Each distinct type of DataPoint represents the output of a specific # aggregation function, the result of applying the DataPoint's # associated function of to one or more measurements. # # All DataPoint types have three common fields: # - Attributes includes key-value pairs associated with the data point # - TimeUnixNano is required, set to the end time of the aggregation # - StartTimeUnixNano is optional, but strongly encouraged for DataPoints having an AggregationTemporality field, as discussed below. # type Metrics @model{ name:String description:String # unit in which the metric value is reported. Follows the format # described by http://unitsofmeasure.org/ucum.html. unit:String # Data determines the aggregation type (if any) of the metric, what is the # reported value type for the data points, as well as the relatationship to the time interval over which they are reported. data:MetricsData } interface MetricsData { points:[DataPoint] type:AggType } # List of exemplars collected from measurements that were used to form the data point type Exemplar { filteredAttributes:JSON value:DataPointValue time:Time spanId:String traceId:String } interface DataPoint { # Attributes includes key-value pairs associated with the data point (AKA dimensions) attributes:JSON # time field is set to the end time of the aggregation time:Time # StartTimeUnixNano in general allows detecting when a sequence of observations is unbroken. This field indicates to consumers the # start time for points with cumulative and delta AggregationTemporality, and it should be included whenever possible # to support correct rate calculation. startTime:Time } # AggregationTemporality defines how a metric aggregator reports aggregated # values. It describes how those values relate to the time interval over # which they are aggregated. enum AggregationTemporality { # DELTA is an AggregationTemporality for a metric aggregator which reports # changes since last report time. Successive metrics contain aggregation of # values from continuous and non-overlapping intervals. # The values for a DELTA metric are based only on the time interval # associated with one measurement cycle. There is no dependency on # previous measurements like is the case for CUMULATIVE metrics. # For example, consider a system measuring the number of requests that # it receives and reports the sum of these requests every second as a # DELTA metric: # 1. The system starts receiving at time=t_0. # 2. A request is received, the system measures 1 request. # 3. A request is received, the system measures 1 request. # 4. A request is received, the system measures 1 request. # 5. The 1 second collection cycle ends. A metric is exported for the # number of requests received over the interval of time t_0 to # t_0+1 with a value of 3. # 6. A request is received, the system measures 1 request. # 7. A request is received, the system measures 1 request. # 8. The 1 second collection cycle ends. A metric is exported for the # number of requests received over the interval of time t_0+1 to # t_0+2 with a value of 2. AGGREGATION_TEMPORALITY_DELTA # CUMULATIVE is an AggregationTemporality for a metric aggregator which # reports changes since a fixed start time. This means that current values # of a CUMULATIVE metric depend on all previous measurements since the # start time. Because of this, the sender is required to retain this state # in some form. If this state is lost or invalidated, the CUMULATIVE metric # values MUST be reset and a new fixed start time following the last # reported measurement time sent MUST be used. # For example, consider a system measuring the number of requests that # it receives and reports the sum of these requests every second as a # CUMULATIVE metric: # 1. The system starts receiving at time=t_0. # 2. A request is received, the system measures 1 request. # 3. A request is received, the system measures 1 request. # 4. A request is received, the system measures 1 request. # 5. The 1 second collection cycle ends. A metric is exported for the # number of requests received over the interval of time t_0 to # t_0+1 with a value of 3. # 6. A request is received, the system measures 1 request. # 7. A request is received, the system measures 1 request. # 8. The 1 second collection cycle ends. A metric is exported for the # number of requests received over the interval of time t_0 to # t_0+2 with a value of 5. # 9. The system experiences a fault and loses state. # 10. The system recovers and resumes receiving at time=t_1. # 11. A request is received, the system measures 1 request. # 12. The 1 second collection cycle ends. A metric is exported for the # number of requests received over the interval of time t_1 to # t_0+1 with a value of 1. # Note: Even though, when reporting changes since last report time, using # CUMULATIVE is valid, it is not recommended. This may cause problems for # systems that do not use start_time to determine when the aggregation # value was reset (e.g. Prometheus). AGGREGATION_TEMPORALITY_CUMULATIVE } # The actual value itself type DataPointValue { valueAsDouble:Float valueAsInt:Int } type QuantileValue { # The quantile of a distribution. Must be in the interval [0.0, 1.0]. quantile:Float # The value at the given quantile of a distribution. value:Float } # NumberDataPoint is a single data point in a timeseries that describes the time-varying scalar value of a metric. type NumberDataPoint implements DataPoint { # Attributes includes key-value pairs associated with the data point (AKA dimensions) attributes:JSON # time field is set to the end time of the aggregation time:Time # StartTimeUnixNano in general allows detecting when a sequence of observations is unbroken. This field indicates to consumers the # start time for points with cumulative and delta AggregationTemporality, and it should be included whenever possible # to support correct rate calculation. startTime:Time value:DataPointValue # (Optional) List of exemplars collected from # measurements that were used to form the data point exemplar:Exemplar } # SummaryDataPoint is a single data point in a timeseries that describes the # time-varying values of a Summary metric. type SummaryDataPoint implements DataPoint { # Attributes includes key-value pairs associated with the data point (AKA dimensions) attributes:JSON # time field is set to the end time of the aggregation time:Time # StartTimeUnixNano in general allows detecting when a sequence of observations is unbroken. This field indicates to consumers the # start time for points with cumulative and delta AggregationTemporality, and it should be included whenever possible # to support correct rate calculation. startTime:Time # sum of the values in the population. If count is zero then this field must be zero. count:Long # sum of the values in the population. If count is zero then this field must be zero. sum : Long # (Optional) list of values at different quantiles of the distribution calculated # from the current snapshot. The quantiles must be strictly increasing. quantileValues:[QuantileValue] } # HistogramDataPoint is a single data point in a timeseries that describes the # time-varying values of a Histogram. A Histogram contains summary statistics # for a population of values, it may optionally contain the distribution of # those values across a set of buckets. # # If the histogram contains the distribution of values, then both # "explicit_bounds" and "bucket counts" fields must be defined. # If the histogram does not contain the distribution of values, then both # "explicit_bounds" and "bucket_counts" must be omitted and only "count" and # "sum" are known. type HistogramDataPoint implements DataPoint { # Attributes includes key-value pairs associated with the data point (AKA dimensions) attributes:JSON # time field is set to the end time of the aggregation time:Time # StartTimeUnixNano in general allows detecting when a sequence of observations is unbroken. This field indicates to consumers the # start time for points with cumulative and delta AggregationTemporality, and it should be included whenever possible # to support correct rate calculation. startTime:Time # sum of the values in the population. If count is zero then this field must be zero. count:Long # bucket_counts is an optional field contains the count values of histogram for each bucket. bucketCounts:[Int] # explicit_bounds specifies buckets with explicitly defined bounds for values. # # The boundaries for bucket at index i are: # # (-infinity, explicit_bounds[i]] for i == 0 # (explicit_bounds[i-1], explicit_bounds[i]] for 0 < i < size(explicit_bounds) # (explicit_bounds[i-1], +infinity) for i == size(explicit_bounds) # # The values in the explicit_bounds array must be strictly increasing. # # Histogram buckets are inclusive of their upper boundary, except the last # bucket where the boundary is at infinity. bucketBounds:[Float] # sum of the values in the population. If count is zero then this field # must be zero. # sum : Long # (Optional) List of exemplars collected from # measurements that were used to form the data point exemplar:Exemplar # min is the minimum value over (start_time, end_time]. min : Float # max is the maximum value over (start_time, end_time]. max : Float } # ExponentialHistogramDataPoint is a single data point in a timeseries that describes the # time-varying values of a ExponentialHistogram of double values. A ExponentialHistogram contains # summary statistics for a population of values, it may optionally contain the # distribution of those values across a set of buckets. type ExponentialHistogramDataPoint implements DataPoint { # Attributes includes key-value pairs associated with the data point (AKA dimensions) attributes:JSON # time field is set to the end time of the aggregation time:Time # StartTimeUnixNano in general allows detecting when a sequence of observations is unbroken. This field indicates to consumers the # start time for points with cumulative and delta AggregationTemporality, and it should be included whenever possible # to support correct rate calculation. startTime:Time # TODO - implement content } # Gauge represents the type of a scalar metric that always exports the # "current value" for every data point. It should be used for an "unknown" # aggregation. # # A Gauge does not support different aggregation temporalities. Given the # aggregation is unknown, points cannot be combined using the same # aggregation, regardless of aggregation temporalities. Therefore, # AggregationTemporality is not included. Consequently, this also means # "StartTimeUnixNano" is ignored for all data points. type Gauge implements MetricsData{ points:[NumberDataPoint] type:AggType } # Sum represents the type of a scalar metric that is calculated as a sum of all reported measurements over a time interval. type Sum implements MetricsData{ points:[SummaryDataPoint] type:AggType # aggregation_temporality describes if the aggregator reports delta changes # since last report time, or cumulative changes since a fixed start time. temporality:AggregationTemporality } # Summary metric data are used to convey quantile summaries data type. # These data points cannot always be merged in a meaningful way. # While they can be useful in some applications, histogram data points are # recommended for new applications. type Summary implements MetricsData{ points:[SummaryDataPoint] type:AggType # aggregation_temporality describes if the aggregator reports delta changes # since last report time, or cumulative changes since a fixed start time. temporality:AggregationTemporality } # Histogram represents the type of a metric that is calculated by aggregating # as a Histogram of all reported measurements over a time interval. type Histogram implements MetricsData{ points:[HistogramDataPoint] type:AggType # aggregation_temporality describes if the aggregator reports delta changes # since last report time, or cumulative changes since a fixed start time. temporality:AggregationTemporality } # ExponentialHistogram represents the type of a metric that is calculated by aggregating # as a ExponentialHistogram of all reported double measurements over a time interval. type ExponentialHistogram implements MetricsData{ points:[ExponentialHistogramDataPoint] type:AggType # aggregation_temporality describes if the aggregator reports delta changes # since last report time, or cumulative changes since a fixed start time. temporality:AggregationTemporality }