Debian Codegraph @

google/api/distribution.proto

raw
1 // Copyright 2026 Google LLC
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14
15 syntax = "proto3";
16
17 package google.api;
18
19 import "google/protobuf/any.proto";
20 import "google/protobuf/timestamp.proto";
21
22 option go_package = "google.golang.org/genproto/googleapis/api/distribution;distribution";
23 option java_multiple_files = true;
24 option java_outer_classname = "DistributionProto";
25 option java_package = "com.google.api";
26 option objc_class_prefix = "GAPI";
27
28 // `Distribution` contains summary statistics for a population of values. It
29 // optionally contains a histogram representing the distribution of those values
30 // across a set of buckets.
31 //
32 // The summary statistics are the count, mean, sum of the squared deviation from
33 // the mean, the minimum, and the maximum of the set of population of values.
34 // The histogram is based on a sequence of buckets and gives a count of values
35 // that fall into each bucket. The boundaries of the buckets are given either
36 // explicitly or by formulas for buckets of fixed or exponentially increasing
37 // widths.
38 //
39 // Although it is not forbidden, it is generally a bad idea to include
40 // non-finite values (infinities or NaNs) in the population of values, as this
41 // will render the `mean` and `sum_of_squared_deviation` fields meaningless.
42 message Distribution {
43 // The range of the population values.
44 message Range {
45 // The minimum of the population values.
46 double min = 1;
47
48 // The maximum of the population values.
49 double max = 2;
50 }
51
52 // `BucketOptions` describes the bucket boundaries used to create a histogram
53 // for the distribution. The buckets can be in a linear sequence, an
54 // exponential sequence, or each bucket can be specified explicitly.
55 // `BucketOptions` does not include the number of values in each bucket.
56 //
57 // A bucket has an inclusive lower bound and exclusive upper bound for the
58 // values that are counted for that bucket. The upper bound of a bucket must
59 // be strictly greater than the lower bound. The sequence of N buckets for a
60 // distribution consists of an underflow bucket (number 0), zero or more
61 // finite buckets (number 1 through N - 2) and an overflow bucket (number N -
62 // 1). The buckets are contiguous: the lower bound of bucket i (i > 0) is the
63 // same as the upper bound of bucket i - 1. The buckets span the whole range
64 // of finite values: lower bound of the underflow bucket is -infinity and the
65 // upper bound of the overflow bucket is +infinity. The finite buckets are
66 // so-called because both bounds are finite.
67 message BucketOptions {
68 // Specifies a linear sequence of buckets that all have the same width
69 // (except overflow and underflow). Each bucket represents a constant
70 // absolute uncertainty on the specific value in the bucket.
71 //
72 // There are `num_finite_buckets + 2` (= N) buckets. Bucket `i` has the
73 // following boundaries:
74 //
75 // Upper bound (0 <= i < N-1): offset + (width * i).
76 //
77 // Lower bound (1 <= i < N): offset + (width * (i - 1)).
78 message Linear {
79 // Must be greater than 0.
80 int32 num_finite_buckets = 1;
81
82 // Must be greater than 0.
83 double width = 2;
84
85 // Lower bound of the first bucket.
86 double offset = 3;
87 }
88
89 // Specifies an exponential sequence of buckets that have a width that is
90 // proportional to the value of the lower bound. Each bucket represents a
91 // constant relative uncertainty on a specific value in the bucket.
92 //
93 // There are `num_finite_buckets + 2` (= N) buckets. Bucket `i` has the
94 // following boundaries:
95 //
96 // Upper bound (0 <= i < N-1): scale * (growth_factor ^ i).
97 //
98 // Lower bound (1 <= i < N): scale * (growth_factor ^ (i - 1)).
99 message Exponential {
100 // Must be greater than 0.
101 int32 num_finite_buckets = 1;
102
103 // Must be greater than 1.
104 double growth_factor = 2;
105
106 // Must be greater than 0.
107 double scale = 3;
108 }
109
110 // Specifies a set of buckets with arbitrary widths.
111 //
112 // There are `size(bounds) + 1` (= N) buckets. Bucket `i` has the following
113 // boundaries:
114 //
115 // Upper bound (0 <= i < N-1): bounds[i]
116 // Lower bound (1 <= i < N); bounds[i - 1]
117 //
118 // The `bounds` field must contain at least one element. If `bounds` has
119 // only one element, then there are no finite buckets, and that single
120 // element is the common boundary of the overflow and underflow buckets.
121 message Explicit {
122 // The values must be monotonically increasing.
123 repeated double bounds = 1;
124 }
125
126 // Exactly one of these three fields must be set.
127 oneof options {
128 // The linear bucket.
129 Linear linear_buckets = 1;
130
131 // The exponential buckets.
132 Exponential exponential_buckets = 2;
133
134 // The explicit buckets.
135 Explicit explicit_buckets = 3;
136 }
137 }
138
139 // Exemplars are example points that may be used to annotate aggregated
140 // distribution values. They are metadata that gives information about a
141 // particular value added to a Distribution bucket, such as a trace ID that
142 // was active when a value was added. They may contain further information,
143 // such as a example values and timestamps, origin, etc.
144 message Exemplar {
145 // Value of the exemplar point. This value determines to which bucket the
146 // exemplar belongs.
147 double value = 1;
148
149 // The observation (sampling) time of the above value.
150 google.protobuf.Timestamp timestamp = 2;
151
152 // Contextual information about the example value. Examples are:
153 //
154 // Trace: type.googleapis.com/google.monitoring.v3.SpanContext
155 //
156 // Literal string: type.googleapis.com/google.protobuf.StringValue
157 //
158 // Labels dropped during aggregation:
159 // type.googleapis.com/google.monitoring.v3.DroppedLabels
160 //
161 // There may be only a single attachment of any given message type in a
162 // single exemplar, and this is enforced by the system.
163 repeated google.protobuf.Any attachments = 3;
164 }
165
166 // The number of values in the population. Must be non-negative. This value
167 // must equal the sum of the values in `bucket_counts` if a histogram is
168 // provided.
169 int64 count = 1;
170
171 // The arithmetic mean of the values in the population. If `count` is zero
172 // then this field must be zero.
173 double mean = 2;
174
175 // The sum of squared deviations from the mean of the values in the
176 // population. For values x_i this is:
177 //
178 // Sum[i=1..n]((x_i - mean)^2)
179 //
180 // Knuth, "The Art of Computer Programming", Vol. 2, page 232, 3rd edition
181 // describes Welford's method for accumulating this sum in one pass.
182 //
183 // If `count` is zero then this field must be zero.
184 double sum_of_squared_deviation = 3;
185
186 // If specified, contains the range of the population values. The field
187 // must not be present if the `count` is zero.
188 Range range = 4;
189
190 // Defines the histogram bucket boundaries. If the distribution does not
191 // contain a histogram, then omit this field.
192 BucketOptions bucket_options = 6;
193
194 // The number of values in each bucket of the histogram, as described in
195 // `bucket_options`. If the distribution does not have a histogram, then omit
196 // this field. If there is a histogram, then the sum of the values in
197 // `bucket_counts` must equal the value in the `count` field of the
198 // distribution.
199 //
200 // If present, `bucket_counts` should contain N values, where N is the number
201 // of buckets specified in `bucket_options`. If you supply fewer than N
202 // values, the remaining values are assumed to be 0.
203 //
204 // The order of the values in `bucket_counts` follows the bucket numbering
205 // schemes described for the three bucket types. The first value must be the
206 // count for the underflow bucket (number 0). The next N-2 values are the
207 // counts for the finite buckets (number 1 through N-2). The N'th value in
208 // `bucket_counts` is the count for the overflow bucket (number N-1).
209 repeated int64 bucket_counts = 7;
210
211 // Must be in increasing order of `value` field.
212 repeated Exemplar exemplars = 10;
213 }