Skip to content
This repository was archived by the owner on Oct 3, 2023. It is now read-only.

Commit 865a05c

Browse files
authored
Gauge vs Cumulative. (#65)
* Gauge vs Cumulative. - Split TimeSeries into GaugeTimeSeries vs CumulativeTimeSeries. - Merge GaugePoint and CumulativePoint into a single Point message to minimize validation. - Remove TODO: we don't validate keys or values.
1 parent 1cc3304 commit 865a05c

1 file changed

Lines changed: 32 additions & 37 deletions

File tree

opencensus/proto/stats/metrics/metrics.proto

Lines changed: 32 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,10 @@ message Metric {
4444
MetricDescriptor metric_descriptor = 1;
4545

4646
// One or more timeseries for a single metric, where each timeseries has
47-
// one or more points.
48-
repeated TimeSeries timeseries = 2;
47+
// one or more points. The type of the timeseries must match
48+
// metric_descriptor.type, so only one of the two should be populated.
49+
repeated GaugeTimeSeries gauge_timeseries = 2;
50+
repeated CumulativeTimeSeries cumulative_timeseries = 3;
4951
}
5052

5153
// Defines a metric type and its schema.
@@ -103,31 +105,43 @@ message LabelKey {
103105
}
104106

105107
// A collection of data points that describes the time-varying values
106-
// of a metric.
107-
message TimeSeries {
108-
// TODO: Add restrictions for characters that can be used for keys and values.
109-
// The set of label values that uniquely identify this timeseries. Apply to all
110-
// points. The order of label values must match that of label keys in the
108+
// of a gauge metric.
109+
message GaugeTimeSeries {
110+
// The set of label values that uniquely identify this timeseries. Applies to
111+
// all points. The order of label values must match that of label keys in the
111112
// metric descriptor.
112113
repeated LabelValue label_values = 1;
113114

114-
// The data points of this timeseries. Point type MUST match the MetricDescriptor.type, so for
115-
// a CUMULATIVE type only cumulative_points are present and for a GAUGE type only gauge_points
116-
// are present.
117-
repeated GaugePoint gauge_points = 2;
118-
repeated CumulativePoint cumulative_points = 3;
115+
// The data points of this timeseries. Point type MUST match the MetricDescriptor.type.
116+
repeated Point points = 2;
117+
}
118+
119+
// A collection of data points that describes the time-varying values
120+
// of a cumulative metric.
121+
message CumulativeTimeSeries {
122+
// The time that the cumulative value was reset to zero.
123+
google.protobuf.Timestamp start_time = 1; // required
124+
125+
// The set of label values that uniquely identify this timeseries. Applies to
126+
// all points. The order of label values must match that of label keys in the
127+
// metric descriptor.
128+
repeated LabelValue label_values = 2;
129+
130+
// The data points of this timeseries. Point type MUST match the MetricDescriptor.type.
131+
repeated Point points = 3;
119132
}
120133

121134
message LabelValue {
122135
// The value for the label.
123136
string value = 1;
124137
// If false the value field is ignored and considered not set.
138+
// This is used to differentiate a missing label from an empty string.
125139
bool has_value = 2;
126140
}
127141

128-
// An instantaneous measurement of a value.
129-
message GaugePoint {
130-
// The moment when this gauge point was recorded.
142+
// A timestamped measurement.
143+
message Point {
144+
// The moment when this point was recorded.
131145
google.protobuf.Timestamp timestamp = 1; // required
132146

133147
// The actual point value.
@@ -138,35 +152,16 @@ message GaugePoint {
138152
// A 64-bit double-precision floating-point number.
139153
double double_value = 3;
140154

155+
// A distribution value.
156+
DistributionValue distribution_value = 4;
157+
141158
// TODO: Add support for Summary type. This is an aggregation that produces
142159
// percentiles directly.
143160
//
144161
// See also: https://prometheus.io/docs/concepts/metric_types/#summary
145162
}
146163
}
147164

148-
// Measurements accumulated over a time interval.
149-
message CumulativePoint {
150-
// This must be the same until an event resets the cumulative value to zero
151-
// and sets a new start for the following points.
152-
google.protobuf.Timestamp start_time = 1; // required
153-
154-
// The end timestamp of the accumulated measurement.
155-
google.protobuf.Timestamp end_time = 2; // required
156-
157-
// The actual point value.
158-
oneof value {
159-
// A 64-bit integer.
160-
int64 int64_value = 3;
161-
162-
// A 64-bit double-precision floating-point number.
163-
double double_value = 4;
164-
165-
// A distribution value.
166-
DistributionValue distribution_value = 5;
167-
}
168-
}
169-
170165
// Distribution contains summary statistics for a population of values. It
171166
// optionally contains a histogram representing the distribution of those
172167
// values across a set of buckets.

0 commit comments

Comments
 (0)