1- // Copyright 2016-17 , OpenCensus Authors
1+ // Copyright 2016-18 , OpenCensus Authors
22//
33// Licensed under the Apache License, Version 2.0 (the "License");
44// you may not use this file except in compliance with the License.
@@ -16,163 +16,91 @@ syntax = "proto3";
1616
1717package opencensus.proto.stats ;
1818
19- import "google/protobuf/duration.proto" ;
2019import "google/protobuf/timestamp.proto" ;
2120
21+ option go_package = "statsproto" ;
2222option java_multiple_files = true ;
2323option java_package = "io.opencensus.proto.stats" ;
2424option java_outer_classname = "StatsProto" ;
2525
26- option go_package = "statsproto" ;
27-
28- // All the census protos.
29- //
30- // Nomenclature notes:
31- // * Capitalized names below (like View) are protos.
32- // * Protos which describe types are named with a Descriptor suffix (e.g.
33- // MesurementDescriptor).
34- //
35- // Census lets you define the type and description of the data being measured
36- // (e.g. the latency of an RPC or the number of CPU cycles spent on an
37- // operation using MeasurementDescriptor. As individual measurements (a double
38- // value) for are recorded, they are aggregated together into an
39- // Aggregation. There are two Aggregation types available: Distribution
40- // (describes the distribution of all measurements, possibly with a histogram)
41- // and IntervalStats (the count and mean of measurements across specified time
42- // periods). An Aggregation is described by an AggregationDescriptor.
43- //
44- // You can define how your measurements (described by a MeasurementDescriptor)
45- // are broken down by Tag values and which Aggregations to use through a
46- // ViewDescriptor. The output (all measurements broken down by tag values into
47- // specific Aggregations) is called a View.
48-
26+ // TODO(bdrutu): Consider if this should be moved to a "tags" directory to match the API structure.
27+ message Tag {
28+ string key = 1 ;
29+ string value = 2 ;
30+ }
4931
50- // MeasurementDescriptor describes a data point (measurement) type.
51- message MeasurementDescriptor {
52- // A descriptive name, e.g. rpc_latency, cpu. Must be unique.
32+ // Measure .
33+ message Measure {
34+ // A string by which the measure will be referred to, e.g. "rpc_server_latency". Names MUST be
35+ // unique within the library.
5336 string name = 1 ;
5437
55- // More detailed description of the resource, used in documentation .
38+ // Describes the measure, e.g. "RPC latency in seconds" .
5639 string description = 2 ;
5740
58- // Fundamental units of measurement supported by Census
59- // TODO(aveitch): expand this to include other S.I. units?
60- enum BasicUnit {
61- UNKNOWN = 0 ; // Implementations should not use this
62- SCALAR = 1 ; // Dimensionless
63- BITS = 2 ; // A single bit
64- BYTES = 3 ; // An 8-bit byte
65- SECONDS = 4 ; // S.I. unit
66- CORES = 5 ; // CPU core usage
67- MAX_UNITS = 6 ; // Last defined value; implementations should only use
68- // this for validation.
69- }
70-
71- // MeasurementUnit lets you build compound units of the form
72- // 10^n * (A * B * ...) / (X * Y * ...),
73- // where the elements in the numerator and denominator are all BasicUnits. A
74- // MeasurementUnit must have at least one BasicUnit in its numerator.
75- //
76- // To specify multiplication in the numerator or denominator, simply specify
77- // multiple numerator or denominator fields. For example:
78- //
79- // - byte-seconds (i.e. bytes * seconds):
80- // numerator: BYTES
81- // numerator: SECS
82- //
83- // - events/sec^2 (i.e. rate of change of events/sec):
84- // numerator: SCALAR
85- // denominator: SECS
86- // denominator: SECS
87- //
88- // To specify multiples (in power of 10) of units, specify a non-zero
89- // 'power10' value, for example:
90- //
91- // - MB/s (i.e. megabytes / s):
92- // power10: 6
93- // numerator: BYTES
94- // denominator: SECS
95- //
96- // - nanoseconds
97- // power10: -9
98- // numerator: SECS
99- message MeasurementUnit {
100- int32 power10 = 1 ;
101- repeated BasicUnit numerators = 2 ;
102- repeated BasicUnit denominators = 3 ;
41+ // Describes the unit used for the Measure. Follows the format described by
42+ // http://unitsofmeasure.org/ucum.html.
43+ string unit = 3 ;
44+
45+ enum Type {
46+ // Unknown type.
47+ TYPE_UNSPECIFIED = 0 ;
48+ // Indicates an int64 Measure.
49+ INT64 = 1 ;
50+ // Indicates a double Measure.
51+ DOUBLE = 2 ;
10352 }
10453
105- // The units used by this type of measurement .
106- MeasurementUnit unit = 3 ;
54+ // The type used for this Measure .
55+ Type type = 4 ;
10756}
10857
109- // An aggregation summarizes a series of individual measurements. There are
110- // two types of aggregation (IntervalAggregation and DistributionAggregation),
111- // unique types of each can be set using descriptors for each.
58+ message View {
59+ // A string by which the View will be referred to, e.g. "rpc_latency". Names MUST be unique
60+ // within the library.
61+ string name = 1 ;
11262
113- // DistributionAggregation contains summary statistics for a population of
114- // values and, optionally, a histogram representing the distribution of those
115- // values across a specified set of histogram buckets, as defined in
116- // DistributionAggregationDescriptor.bucket_bounds.
117- //
118- // The summary statistics are the count, mean, minimum, and the maximum of the
119- // set of population of values.
120- //
121- // Although it is not forbidden, it is generally a bad idea to include
122- // non-finite values (infinities or NaNs) in the population of values, as this
123- // will render the `mean` field meaningless.
124- message DistributionAggregation {
125- // The number of values in the population. Must be non-negative.
126- int64 count = 1 ;
63+ // Describes the view, e.g. "RPC latency distribution"
64+ string description = 2 ;
12765
128- // The arithmetic mean of the values in the population. If `count` is zero
129- // then this field must be zero.
130- double mean = 2 ;
66+ // The Measure to which this view is applied.
67+ Measure measure = 3 ;
13168
132- // The sum of the values in the population. If `count` is zero then this
133- // field must be zero.
134- double sum = 3 ;
69+ // An array of tag keys. These values associated with tags of this name form the basis by which
70+ // individual stats will be aggregated (one aggregation per unique tag value). If none are
71+ // provided, then all data is recorded in a single aggregation.
72+ repeated string columns = 4 ;
13573
136- // Describes a range of population values.
137- message Range {
138- // The minimum of the population values.
139- double min = 1 ;
140- // The maximum of the population values.
141- double max = 2 ;
74+ // The description of the aggregation used for this view which describes how data collected are
75+ // aggregated.
76+ oneof aggregation {
77+ // Counts the number of measurements recorded.
78+ CountAggregation count_aggregation = 5 ;
79+ // Indicates that data collected and aggregated with this Aggregation will be summed up.
80+ SumAggregation sum_aggregation = 6 ;
81+ // Indicates that data collected and aggregated with this Aggregation will represent the last
82+ // recorded value. This is useful to support Gauges.
83+ LastValueAggregation last_value_aggregation = 7 ;
84+ // Indicates that the desired Aggregation is a histogram distribution. A distribution
85+ // Aggregation may contain a histogram of the values in the population. User should define the
86+ // bucket boundaries for that histogram (see DistributionAggregation).
87+ DistributionAggregation distribution_aggregation = 8 ;
14288 }
89+ }
14390
144- // The range of the population values. If `count` is zero, this field will not
145- // be defined.
146- Range range = 4 ;
91+ message CountAggregation {}
14792
148- // A Distribution may optionally contain a histogram of the values in the
149- // population. The histogram is given in `bucket_count` as counts of values
150- // that fall into one of a sequence of non-overlapping buckets, as described
151- // by `DistributionAggregationDescriptor.bucket_boundaries`. The sum of the
152- // values in `bucket_counts` must equal the value in `count`.
153- //
154- // Bucket counts are given in order under the numbering scheme described
155- // above (the underflow bucket has number 0; the finite buckets, if any,
156- // have numbers 1 through N-2; the overflow bucket has number N-1).
157- //
158- // The size of `bucket_count` must be no greater than N as defined in
159- // `bucket_boundaries`.
160- //
161- // Any suffix of trailing zero bucket_count fields may be omitted.
162- repeated int64 bucket_counts = 5 ;
93+ message SumAggregation {}
16394
164- // Tags associated with this DistributionAggregation. These will be filled
165- // in based on the View specification.
166- repeated Tag tags = 6 ;
167- }
95+ message LastValueAggregation {}
16896
169- message DistributionAggregationDescriptor {
97+ message DistributionAggregation {
17098 // A Distribution may optionally contain a histogram of the values in the
17199 // population. The bucket boundaries for that histogram are described by
172100 // `bucket_bounds`. This defines `size(bucket_bounds) + 1` (= N)
173101 // buckets. The boundaries for bucket index i are:
174102 //
175- // [ -infinity, bucket_bounds[i]) for i == 0
103+ // ( -infinity, bucket_bounds[i]) for i == 0
176104 // [bucket_bounds[i-1], bucket_bounds[i]) for 0 < i < N-2
177105 // [bucket_bounds[i-1], +infinity) for i == N-1
178106 //
@@ -188,104 +116,20 @@ message DistributionAggregationDescriptor {
188116 repeated double bucket_bounds = 1 ;
189117}
190118
191- // An IntervalAggreation records summary stats over various time
192- // windows. These stats are approximate, with the degree of accuracy
193- // controlled by setting the n_sub_intervals parameter in the
194- // IntervalAggregationDescriptor.
195- message IntervalAggregation {
196- // Summary statistic over a single time interval.
197- message Interval {
198- // The interval duration. Must be positive.
199- google.protobuf.Duration interval_size = 1 ;
200- // Approximate number of measurements recorded in this interval.
201- double count = 2 ;
202- // The cumulative sum of measurements in this interval.
203- double sum = 3 ;
204- }
205-
206- // Full set of intervals for this aggregation.
207- repeated Interval intervals = 1 ;
208-
209- // Tags associated with this IntervalAggregation. These will be filled in
210- // based on the View specification.
211- repeated Tag tags = 2 ;
212- }
213-
214- // An IntervalAggreationDescriptor specifies time intervals for an
215- // IntervalAggregation.
216- message IntervalAggregationDescriptor {
217- // Number of internal sub-intervals to use when collecting stats for each
218- // interval. The max error in interval measurements will be approximately
219- // 1/n_sub_intervals (although in practice, this will only be approached in
220- // the presence of very large and bursty workload changes), and underlying
221- // memory usage will be roughly proportional to the value of this
222- // field. Must be in the range [2, 20]. A value of 5 will be used if this is
223- // unspecified.
224- int32 n_sub_intervals = 1 ;
225-
226- // The size of each interval, as a time duration. Must have at least one
227- // element.
228- repeated google.protobuf.Duration interval_sizes = 2 ;
229- }
230-
231- // A Tag: key-value pair.
232- // Both strings must be printable ASCII.
233- message Tag {
234- string key = 1 ;
235- string value = 2 ;
236- }
237-
238- // A ViewDescriptor specifies an AggregationDescriptor and a set of tag
239- // keys. Views instantiated from this descriptor will contain Aggregations
240- // broken down by the unique set of matching tag values for each measurement.
241- message ViewDescriptor {
242- // Name of view. Must be unique.
243- string name = 1 ;
244-
245- // More detailed description, for documentation purposes.
246- string description = 2 ;
119+ // Describes a data point to be collected for a Measure.
120+ message Measurement {
121+ repeated Tag tags = 1 ;
247122
248- // Name of a MeasurementDescriptor to be used for this view .
249- string measurement_descriptor_name = 3 ;
123+ // The name of the measure to which the value is applied .
124+ string measure_name = 2 ;
250125
251- // Aggregation type to associate with View .
252- oneof aggregation {
253- IntervalAggregationDescriptor interval_aggregation = 4 ;
254- DistributionAggregationDescriptor distribution_aggregation = 5 ;
126+ // The recorded value, MUST have the appropriate type to match the Measure .
127+ oneof value {
128+ double double_value = 3 ;
129+ int64 int_value = 4 ;
255130 }
256131
257- // Tag keys to match with a given measurement. If no keys are specified,
258- // then all stats are recorded. Keys must be unique.
259- repeated string tag_keys = 6 ;
260- }
261-
262- // DistributionView contains all aggregations for a view specified using a
263- // DistributionAggregationDescriptor.
264- message DistributionView {
265- // Aggregations - each will have a unique set of tag values for the tag_keys
266- // associated with the corresponding View.
267- repeated DistributionAggregation aggregations = 1 ;
268-
269- // Start and end timestamps over which aggregations was accumulated.
270- google.protobuf.Timestamp start = 2 ;
271- google.protobuf.Timestamp end = 3 ;
272- }
273-
274- // IntervalView contains all aggregations for a view specified using a
275- // IntervalAggregationDescriptor.
276- message IntervalView {
277- // Aggregations - each will have a unique set of tag values for the tag_keys
278- // associated with the corresponding View.
279- repeated IntervalAggregation aggregations = 1 ;
280- }
281-
282- // A View contains the aggregations based on a ViewDescriptor.
283- message View {
284- // ViewDescriptor name associated with this set of View.
285- string view_name = 1 ;
286-
287- oneof view {
288- DistributionView distribution_view = 2 ;
289- IntervalView interval_view = 3 ;
290- }
132+ // The time when this measurement was recorded. If the implementation uses a async buffer to
133+ // record measurements this may be the time when the measurement was read from the buffer.
134+ google.protobuf.Timestamp time = 5 ;
291135}
0 commit comments