xref: /aosp_15_r20/external/googleapis/google/api/servicecontrol/v1/distribution.proto (revision d5c09012810ac0c9f33fe448fb6da8260d444cc9)
1// Copyright 2021 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
15syntax = "proto3";
16
17package google.api.servicecontrol.v1;
18
19import "google/api/distribution.proto";
20
21option cc_enable_arenas = true;
22option csharp_namespace = "Google.Cloud.ServiceControl.V1";
23option go_package = "cloud.google.com/go/servicecontrol/apiv1/servicecontrolpb;servicecontrolpb";
24option java_multiple_files = true;
25option java_outer_classname = "DistributionProto";
26option java_package = "com.google.api.servicecontrol.v1";
27option php_namespace = "Google\\Cloud\\ServiceControl\\V1";
28option ruby_package = "Google::Cloud::ServiceControl::V1";
29
30// Distribution represents a frequency distribution of double-valued sample
31// points. It contains the size of the population of sample points plus
32// additional optional information:
33//
34// * the arithmetic mean of the samples
35// * the minimum and maximum of the samples
36// * the sum-squared-deviation of the samples, used to compute variance
37// * a histogram of the values of the sample points
38message Distribution {
39  // Describing buckets with constant width.
40  message LinearBuckets {
41    // The number of finite buckets. With the underflow and overflow buckets,
42    // the total number of buckets is `num_finite_buckets` + 2.
43    // See comments on `bucket_options` for details.
44    int32 num_finite_buckets = 1;
45
46    // The i'th linear bucket covers the interval
47    //   [offset + (i-1) * width, offset + i * width)
48    // where i ranges from 1 to num_finite_buckets, inclusive.
49    // Must be strictly positive.
50    double width = 2;
51
52    // The i'th linear bucket covers the interval
53    //   [offset + (i-1) * width, offset + i * width)
54    // where i ranges from 1 to num_finite_buckets, inclusive.
55    double offset = 3;
56  }
57
58  // Describing buckets with exponentially growing width.
59  message ExponentialBuckets {
60    // The number of finite buckets. With the underflow and overflow buckets,
61    // the total number of buckets is `num_finite_buckets` + 2.
62    // See comments on `bucket_options` for details.
63    int32 num_finite_buckets = 1;
64
65    // The i'th exponential bucket covers the interval
66    //   [scale * growth_factor^(i-1), scale * growth_factor^i)
67    // where i ranges from 1 to num_finite_buckets inclusive.
68    // Must be larger than 1.0.
69    double growth_factor = 2;
70
71    // The i'th exponential bucket covers the interval
72    //   [scale * growth_factor^(i-1), scale * growth_factor^i)
73    // where i ranges from 1 to num_finite_buckets inclusive.
74    // Must be > 0.
75    double scale = 3;
76  }
77
78  // Describing buckets with arbitrary user-provided width.
79  message ExplicitBuckets {
80    // 'bound' is a list of strictly increasing boundaries between
81    // buckets. Note that a list of length N-1 defines N buckets because
82    // of fenceposting. See comments on `bucket_options` for details.
83    //
84    // The i'th finite bucket covers the interval
85    //   [bound[i-1], bound[i])
86    // where i ranges from 1 to bound_size() - 1. Note that there are no
87    // finite buckets at all if 'bound' only contains a single element; in
88    // that special case the single bound defines the boundary between the
89    // underflow and overflow buckets.
90    //
91    // bucket number                   lower bound    upper bound
92    //  i == 0 (underflow)              -inf           bound[i]
93    //  0 < i < bound_size()            bound[i-1]     bound[i]
94    //  i == bound_size() (overflow)    bound[i-1]     +inf
95    repeated double bounds = 1;
96  }
97
98  // The total number of samples in the distribution. Must be >= 0.
99  int64 count = 1;
100
101  // The arithmetic mean of the samples in the distribution. If `count` is
102  // zero then this field must be zero.
103  double mean = 2;
104
105  // The minimum of the population of values. Ignored if `count` is zero.
106  double minimum = 3;
107
108  // The maximum of the population of values. Ignored if `count` is zero.
109  double maximum = 4;
110
111  // The sum of squared deviations from the mean:
112  //   Sum[i=1..count]((x_i - mean)^2)
113  // where each x_i is a sample values. If `count` is zero then this field
114  // must be zero, otherwise validation of the request fails.
115  double sum_of_squared_deviation = 5;
116
117  // The number of samples in each histogram bucket. `bucket_counts` are
118  // optional. If present, they must sum to the `count` value.
119  //
120  // The buckets are defined below in `bucket_option`. There are N buckets.
121  // `bucket_counts[0]` is the number of samples in the underflow bucket.
122  // `bucket_counts[1]` to `bucket_counts[N-1]` are the numbers of samples
123  // in each of the finite buckets. And `bucket_counts[N] is the number
124  // of samples in the overflow bucket. See the comments of `bucket_option`
125  // below for more details.
126  //
127  // Any suffix of trailing zeros may be omitted.
128  repeated int64 bucket_counts = 6;
129
130  // Defines the buckets in the histogram. `bucket_option` and `bucket_counts`
131  // must be both set, or both unset.
132  //
133  // Buckets are numbered in the range of [0, N], with a total of N+1 buckets.
134  // There must be at least two buckets (a single-bucket histogram gives
135  // no information that isn't already provided by `count`).
136  //
137  // The first bucket is the underflow bucket which has a lower bound
138  // of -inf. The last bucket is the overflow bucket which has an
139  // upper bound of +inf. All other buckets (if any) are called "finite"
140  // buckets because they have finite lower and upper bounds. As described
141  // below, there are three ways to define the finite buckets.
142  //
143  //   (1) Buckets with constant width.
144  //   (2) Buckets with exponentially growing widths.
145  //   (3) Buckets with arbitrary user-provided widths.
146  //
147  // In all cases, the buckets cover the entire real number line (-inf,
148  // +inf). Bucket upper bounds are exclusive and lower bounds are
149  // inclusive. The upper bound of the underflow bucket is equal to the
150  // lower bound of the smallest finite bucket; the lower bound of the
151  // overflow bucket is equal to the upper bound of the largest finite
152  // bucket.
153  oneof bucket_option {
154    // Buckets with constant width.
155    LinearBuckets linear_buckets = 7;
156
157    // Buckets with exponentially growing width.
158    ExponentialBuckets exponential_buckets = 8;
159
160    // Buckets with arbitrary user-provided width.
161    ExplicitBuckets explicit_buckets = 9;
162  }
163
164  // Example points. Must be in increasing order of `value` field.
165  repeated google.api.Distribution.Exemplar exemplars = 10;
166}
167