distribution.proto 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. // Copyright 2016 Google Inc.
  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. syntax = "proto3";
  15. package google.api;
  16. import "google/api/annotations.proto";
  17. import "google/protobuf/any.proto";
  18. import "google/protobuf/timestamp.proto";
  19. option java_multiple_files = true;
  20. option java_outer_classname = "DistributionProto";
  21. option java_package = "com.google.api";
  22. // Distribution contains summary statistics for a population of values and,
  23. // optionally, a histogram representing the distribution of those values across
  24. // a specified set of histogram buckets.
  25. //
  26. // The summary statistics are the count, mean, sum of the squared deviation from
  27. // the mean, the minimum, and the maximum of the set of population of values.
  28. //
  29. // The histogram is based on a sequence of buckets and gives a count of values
  30. // that fall into each bucket. The boundaries of the buckets are given either
  31. // explicitly or by specifying parameters for a method of computing them
  32. // (buckets of fixed width or buckets of exponentially increasing width).
  33. //
  34. // Although it is not forbidden, it is generally a bad idea to include
  35. // non-finite values (infinities or NaNs) in the population of values, as this
  36. // will render the `mean` and `sum_of_squared_deviation` fields meaningless.
  37. message Distribution {
  38. // The range of the population values.
  39. message Range {
  40. // The minimum of the population values.
  41. double min = 1;
  42. // The maximum of the population values.
  43. double max = 2;
  44. }
  45. // A Distribution may optionally contain a histogram of the values in the
  46. // population. The histogram is given in `bucket_counts` as counts of values
  47. // that fall into one of a sequence of non-overlapping buckets. The sequence
  48. // of buckets is described by `bucket_options`.
  49. //
  50. // A bucket specifies an inclusive lower bound and exclusive upper bound for
  51. // the values that are counted for that bucket. The upper bound of a bucket
  52. // is strictly greater than the lower bound.
  53. //
  54. // The sequence of N buckets for a Distribution consists of an underflow
  55. // bucket (number 0), zero or more finite buckets (number 1 through N - 2) and
  56. // an overflow bucket (number N - 1). The buckets are contiguous: the lower
  57. // bound of bucket i (i > 0) is the same as the upper bound of bucket i - 1.
  58. // The buckets span the whole range of finite values: lower bound of the
  59. // underflow bucket is -infinity and the upper bound of the overflow bucket is
  60. // +infinity. The finite buckets are so-called because both bounds are
  61. // finite.
  62. //
  63. // `BucketOptions` describes bucket boundaries in one of three ways. Two
  64. // describe the boundaries by giving parameters for a formula to generate
  65. // boundaries and one gives the bucket boundaries explicitly.
  66. //
  67. // If `bucket_boundaries` is not given, then no `bucket_counts` may be given.
  68. message BucketOptions {
  69. // Specify a sequence of buckets that all have the same width (except
  70. // overflow and underflow). Each bucket represents a constant absolute
  71. // uncertainty on the specific value in the bucket.
  72. //
  73. // Defines `num_finite_buckets + 2` (= N) buckets with these boundaries for
  74. // bucket `i`:
  75. //
  76. // Upper bound (0 <= i < N-1): offset + (width * i).
  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. // Must be greater than 0.
  82. double width = 2;
  83. // Lower bound of the first bucket.
  84. double offset = 3;
  85. }
  86. // Specify a sequence of buckets that have a width that is proportional to
  87. // the value of the lower bound. Each bucket represents a constant relative
  88. // uncertainty on a specific value in the bucket.
  89. //
  90. // Defines `num_finite_buckets + 2` (= N) buckets with these boundaries for
  91. // bucket i:
  92. //
  93. // Upper bound (0 <= i < N-1): scale * (growth_factor ^ i).
  94. // Lower bound (1 <= i < N): scale * (growth_factor ^ (i - 1)).
  95. message Exponential {
  96. // Must be greater than 0.
  97. int32 num_finite_buckets = 1;
  98. // Must be greater than 1.
  99. double growth_factor = 2;
  100. // Must be greater than 0.
  101. double scale = 3;
  102. }
  103. // A set of buckets with arbitrary widths.
  104. //
  105. // Defines `size(bounds) + 1` (= N) buckets with these boundaries for
  106. // bucket i:
  107. //
  108. // Upper bound (0 <= i < N-1): bounds[i]
  109. // Lower bound (1 <= i < N); bounds[i - 1]
  110. //
  111. // There must be at least one element in `bounds`. If `bounds` has only one
  112. // element, there are no finite buckets, and that single element is the
  113. // common boundary of the overflow and underflow buckets.
  114. message Explicit {
  115. // The values must be monotonically increasing.
  116. repeated double bounds = 1;
  117. }
  118. // Exactly one of these three fields must be set.
  119. oneof options {
  120. // The linear bucket.
  121. Linear linear_buckets = 1;
  122. // The exponential buckets.
  123. Exponential exponential_buckets = 2;
  124. // The explicit buckets.
  125. Explicit explicit_buckets = 3;
  126. }
  127. }
  128. // The number of values in the population. Must be non-negative.
  129. int64 count = 1;
  130. // The arithmetic mean of the values in the population. If `count` is zero
  131. // then this field must be zero.
  132. double mean = 2;
  133. // The sum of squared deviations from the mean of the values in the
  134. // population. For values x_i this is:
  135. //
  136. // Sum[i=1..n]((x_i - mean)^2)
  137. //
  138. // Knuth, "The Art of Computer Programming", Vol. 2, page 323, 3rd edition
  139. // describes Welford's method for accumulating this sum in one pass.
  140. //
  141. // If `count` is zero then this field must be zero.
  142. double sum_of_squared_deviation = 3;
  143. // If specified, contains the range of the population values. The field
  144. // must not be present if the `count` is zero.
  145. Range range = 4;
  146. // Defines the histogram bucket boundaries.
  147. BucketOptions bucket_options = 6;
  148. // If `bucket_options` is given, then the sum of the values in `bucket_counts`
  149. // must equal the value in `count`. If `bucket_options` is not given, no
  150. // `bucket_counts` fields may be given.
  151. //
  152. // Bucket counts are given in order under the numbering scheme described
  153. // above (the underflow bucket has number 0; the finite buckets, if any,
  154. // have numbers 1 through N-2; the overflow bucket has number N-1).
  155. //
  156. // The size of `bucket_counts` must be no greater than N as defined in
  157. // `bucket_options`.
  158. //
  159. // Any suffix of trailing zero bucket_count fields may be omitted.
  160. repeated int64 bucket_counts = 7;
  161. }