distribution.proto 8.5 KB

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