blob: c869d851ff1394440a8c23ae156e1a27b6415d90 [file] [log] [blame]
Alistair Veitchfb461ba2016-05-24 10:08:07 -07001// Copyright 2016, Google Inc.
2// All rights reserved.
3//
4// Redistribution and use in source and binary forms, with or without
5// modification, are permitted provided that the following conditions are
6// met:
7//
8// * Redistributions of source code must retain the above copyright
9// notice, this list of conditions and the following disclaimer.
10// * Redistributions in binary form must reproduce the above
11// copyright notice, this list of conditions and the following disclaimer
12// in the documentation and/or other materials provided with the
13// distribution.
14// * Neither the name of Google Inc. nor the names of its
15// contributors may be used to endorse or promote products derived from
16// this software without specific prior written permission.
17//
18// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29
30syntax = "proto3";
31
32package google.census;
33
34// All the census protos.
35//
36// Nomenclature note: capitalized names below (like Metric) are protos.
37//
38// Census lets you define a Metric - something which can be measured, like the
39// latency of an RPC, the number of CPU cycles spent on an operation, or
40// anything else you care to measure. You can record individual instances of
41// measurements (a double value) for every metric of interest. These
42// individual measurements are aggregated together into an Aggregation. There
43// are two Aggregation types available: Distribution (describes the
44// distribution of all measurements, possibly with a histogram) and
45// IntervalStats (the count and mean of measurements across specified time
46// periods). An Aggregation is described by an AggregationDescriptor.
47//
48// You can define how your stats are broken down by Tag values and which
49// Aggregations to use through a View. The corresponding combination of
50// Metric/View/Aggregation which is available to census clients is called a
51// ViewAggregation.
52
53
54// The following two types are copied from
55// google/protobuf/{duration,timestamp}.proto. Ideally, we would be able to
56// import them, but this causes compilation issues on C-based systems
57// (e.g. https://koti.kapsi.fi/jpa/nanopb/), which cannot process the C++
58// headers generated from the standard protobuf distribution. See the relevant
59// proto files for full documentation of these types.
60
61message Duration {
62 // Signed seconds of the span of time. Must be from -315,576,000,000
63 // to +315,576,000,000 inclusive.
64 int64 seconds = 1;
65
66 // Signed fractions of a second at nanosecond resolution of the span
67 // of time. Durations less than one second are represented with a 0
68 // `seconds` field and a positive or negative `nanos` field. For durations
69 // of one second or more, a non-zero value for the `nanos` field must be
70 // of the same sign as the `seconds` field. Must be from -999,999,999
71 // to +999,999,999 inclusive.
72 int32 nanos = 2;
73}
74
75message Timestamp {
76 // Represents seconds of UTC time since Unix epoch
77 // 1970-01-01T00:00:00Z. Must be from from 0001-01-01T00:00:00Z to
78 // 9999-12-31T23:59:59Z inclusive.
79 int64 seconds = 1;
80
81 // Non-negative fractions of a second at nanosecond resolution. Negative
82 // second values with fractions must still have non-negative nanos values
83 // that count forward in time. Must be from 0 to 999,999,999
84 // inclusive.
85 int32 nanos = 2;
86}
87
88// Describes a metric
89message Metric {
90 // name of metric, e.g. rpc_latency, cpu.
91 string name = 1;
92
93 // More detailed description of the metric, used in documentation.
94 string description = 2;
95
96 // Fundamental units of measurement supported by Census
97 // TODO(aveitch): expand this to include other S.I. units?
98 message BasicUnit {
99 enum Measure {
100 UNKNOWN = 0;
101 BITS = 1;
102 BYTES = 2;
103 SECS = 3;
104 CORES = 4;
105 MAX_UNITS = 5;
106 }
107 Measure type = 1;
108 }
109
110 // MeasurementUnit lets you build compound units of the form
111 // 10^n * (A * B * ...) / (X * Y * ...),
112 // where the elements in the numerator and denominator are all BasicUnits. A
113 // MeasurementUnit must have at least one BasicUnit in its numerator.
114 //
115 // To specify multiplication in the numerator or denominator, simply specify
116 // multiple numerator or denominator fields. For example:
117 //
118 // - byte-seconds (i.e. bytes * seconds):
119 // numerator: BYTES
120 // numerator: SECS
121 //
122 // - events/sec^2 (i.e. rate of change of events/sec):
123 // numerator: COUNT
124 // denominator: SECS
125 // denominator: SECS
126 //
127 // To specify multiples (in power of 10) units, specify a non-zero prefix
128 // value, for example:
129 //
130 // - MB/s (i.e. megabytes / s):
131 // prefix: 6
132 // numerator: BYTES
133 // denominator: SECS
134 //
135 // - nanoseconds
136 // prefix: -9
137 // numerator: SECS
138 message MeasurementUnit {
139 int32 prefix = 1;
140 repeated BasicUnit numerator = 2;
141 repeated BasicUnit denominator = 3;
142 }
143
144 // The units in which the Metric value is reported.
145 MeasurementUnit unit = 3;
146
147 // Metrics will be assigned an ID when registered. Invalid if <= 0.
148 int32 id = 4;
149}
150
151// An Aggregation summarizes a series of individual Metric measurements, an
152// AggregationDescriptor describes an Aggregation.
153message AggregationDescriptor {
154 // At most one set of options. If neither option is set, a default type
155 // of Distribution (without a histogram component) will be used.
156 oneof options {
157 // Defines the histogram bucket boundaries for Distributions.
158 BucketBoundaries bucket_boundaries = 1;
159 // Defines the time windows to record for IntervalStats.
160 IntervalBoundaries interval_boundaries = 2;
161 }
162
163 // A Distribution may optionally contain a histogram of the values in the
164 // population. The bucket boundaries for that histogram is described by
165 // `bucket_boundaries`.
166 //
167 // Describes histogram bucket boundaries. Defines `size(bounds) + 1` (= N)
168 // buckets (for size(bounds) >= 1; if size(bounds) == 0, then no histogram
169 // will be defined. The boundaries for bucket index i are:
170 //
171 // [-infinity, bounds[i]) for i == 0
172 // [bounds[i-1], bounds[i]) for 0 < i < N-2
173 // [bounds[i-1], +infinity) for i == N-1
174 //
175 // i.e. an underflow bucket (number 0), zero or more finite buckets (1
176 // through N - 2, and an overflow bucket (N - 1), with inclusive lower
177 // bounds and exclusive upper bounds.
178 //
179 // There must be at least one element in `bounds`. If `bounds` has only one
180 // element, there are no finite buckets, and that single element is the
181 // common boundary of the overflow and underflow buckets.
182 message BucketBoundaries {
183 // The values must be monotonically increasing.
184 repeated double bounds = 1;
185 }
186
187 // For Interval stats, describe the size of each window.
188 message IntervalBoundaries {
189 // For each time window, specify a duration in seconds.
190 repeated double window_size = 1;
191 }
192}
193
194// Distribution contains summary statistics for a population of values and,
195// optionally, a histogram representing the distribution of those values across
196// a specified set of histogram buckets, as defined in
197// Aggregation.bucket_options.
198//
199// The summary statistics are the count, mean, sum of the squared deviation from
200// the mean, the minimum, and the maximum of the set of population of values.
201//
202// Although it is not forbidden, it is generally a bad idea to include
203// non-finite values (infinities or NaNs) in the population of values, as this
204// will render the `mean` field meaningless.
205message Distribution {
206 // The number of values in the population. Must be non-negative.
207 int64 count = 1;
208
209 // The arithmetic mean of the values in the population. If `count` is zero
210 // then this field must be zero.
211 double mean = 2;
212
213 // Describes a range of population values.
214 message Range {
215 // The minimum of the population values.
216 double min = 1;
217 // The maximum of the population values.
218 double max = 2;
219 }
220
221 // The range of the population values. If `count` is zero, this field will not
222 // be defined.
223 Range range = 3;
224
225 // A Distribution may optionally contain a histogram of the values in the
226 // population. The histogram is given in `bucket_count` as counts of values
227 // that fall into one of a sequence of non-overlapping buckets, as described
228 // by `AggregationDescriptor.options.bucket_boundaries`.
229 // The sum of the values in `bucket_counts` must equal the value in `count`.
230 //
231 // Bucket counts are given in order under the numbering scheme described
232 // above (the underflow bucket has number 0; the finite buckets, if any,
233 // have numbers 1 through N-2; the overflow bucket has number N-1).
234 //
235 // The size of `bucket_count` must be no greater than N as defined in
236 // `bucket_boundaries`.
237 //
238 // Any suffix of trailing zero bucket_count fields may be omitted.
239 repeated int64 bucket_count = 4;
240}
241
242// Record summary stats over various time windows.
243message IntervalStats {
244 // Summary statistic over a single time window.
245 message Window {
246 // The window duration.
247 Duration window_size = 1;
248 // The number of measurements in this window.
249 int64 count = 2;
250 // The arithmetic mean of all measurements in the window.
251 double mean = 3;
252 }
253
254 // Full set of windows for this metric.
255 repeated Window window = 1;
256}
257
258// A Tag: key-value pair.
259message Tag {
260 string key = 1;
261 string value = 2;
262}
263
264// A View specifies an Aggregation and a set of tag keys. The Aggregation will
265// be broken down by the unique set of matching tag values for each measurement.
266message View {
267 // Name of view.
268 string name = 1;
269
270 // More detailed description, for documentation purposes.
271 string description = 2;
272
273 // ID of Metric to associate with this View.
274 int32 metric_id = 3;
275
276 // Aggregation type to associate with this View.
277 AggregationDescriptor aggregation = 4;
278
279 // Tag keys to match with a given Metric. If no keys are specified, then all
280 // stats for the Metric are recorded. Keys must be unique.
281 repeated string tag_key = 5;
282}
283
284// An Aggregation summarizes a series of individual Metric measures.
285message Aggregation {
286 // Name of this aggregation.
287 string name = 1;
288
289 // More detailed description, for documentation purposes.
290 string description = 2;
291
292 // The data for this Aggregation.
293 oneof data {
294 Distribution distribution = 3;
295 IntervalStats interval_stats = 4;
296 }
297
298 // Tags associated with this Aggregation.
299 repeated Tag tag = 5;
300}
301
302// A ViewAggregations represents all the Aggregations for a particular view.
303message ViewAggregations {
304 // Aggregations - each will have a unique set of tag values for the tag_keys
305 // associated with the corresponding View.
306 repeated Aggregation aggregation = 1;
307
308 // Start and end timestamps over which the value was accumulated. These
309 // values are not relevant/defined for IntervalStats aggregations, which are
310 // always accumulated over a fixed time period.
311 Timestamp start = 2;
312 Timestamp end = 3;
313}