|
| 1 | +// Copyright 2018, OpenCensus Authors |
| 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 opencensus.proto.stats.metrics; |
| 18 | + |
| 19 | +import "google/protobuf/timestamp.proto"; |
| 20 | + |
| 21 | +option go_package = "metricsproto"; |
| 22 | +option java_multiple_files = true; |
| 23 | +option java_package = "io.opencensus.proto.metrics"; |
| 24 | +option java_outer_classname = "MetricsProto"; |
| 25 | + |
| 26 | +// A collection of Metrics. |
| 27 | +message MetricSet { |
| 28 | + // Each Metric has one or more timeseries. |
| 29 | + repeated Metric metrics = 1; |
| 30 | +} |
| 31 | + |
| 32 | +// Defines a Metric which has one or more timeseries. |
| 33 | +message Metric { |
| 34 | + // The description of the metric. |
| 35 | + MetricDescriptor metric_descriptor = 1; |
| 36 | + |
| 37 | + // One or more timeseries for a single metric, where each timeseries has |
| 38 | + // one or more points. |
| 39 | + repeated TimeSeries timeseries = 2; |
| 40 | +} |
| 41 | + |
| 42 | +// Defines a metric type and its schema. |
| 43 | +message MetricDescriptor { |
| 44 | + // TODO: Add restrictions for characters that can be used. |
| 45 | + // The metric type, including its DNS name prefix. It must be unique. |
| 46 | + string name = 1; |
| 47 | + |
| 48 | + // A detailed description of the metric, which can be used in documentation. |
| 49 | + string description = 2; |
| 50 | + |
| 51 | + // The unit in which the metric value is reported. Follows the format |
| 52 | + // described by http://unitsofmeasure.org/ucum.html. |
| 53 | + string unit = 3; |
| 54 | + |
| 55 | + // The kind of metric. It describes how the data is reported. |
| 56 | + enum Type { |
| 57 | + // Do not use this default value. |
| 58 | + UNSPECIFIED = 0; |
| 59 | + |
| 60 | + // An instantaneous measurement of a value. |
| 61 | + GAUGE = 1; |
| 62 | + |
| 63 | + // A value accumulated over a time interval. Cumulative measurements in a |
| 64 | + // time series should have the same start time and increasing end times, |
| 65 | + // until an event resets the cumulative value to zero and sets a new |
| 66 | + // start time for the following points. |
| 67 | + CUMULATIVE = 2; |
| 68 | + } |
| 69 | + Type type = 4; |
| 70 | + |
| 71 | + // TODO: Consider to add LabelInfo{key, description} if needed. |
| 72 | +} |
| 73 | + |
| 74 | +// A collection of data points that describes the time-varying values |
| 75 | +// of a metric. |
| 76 | +message TimeSeries { |
| 77 | + // TODO: Add restrictions for characters that can be used for keys and values. |
| 78 | + // The set of label values that uniquely identify this timeseries. Apply to all |
| 79 | + // points. |
| 80 | + map<string, string> label = 1; |
| 81 | + |
| 82 | + // The data points of this timeseries. Point type MUST match the MetricDescriptor.type, so for |
| 83 | + // a CUMULATIVE type only cumulative_points are present and for a GAUGE type only gauge_points |
| 84 | + // are present. |
| 85 | + repeated GaugePoint gauge_points = 2; |
| 86 | + repeated CumulativePoint cumulative_points = 3; |
| 87 | +} |
| 88 | + |
| 89 | +// An instantaneous measurement of a value. |
| 90 | +message GaugePoint { |
| 91 | + // The moment when this gauge point was recorded. |
| 92 | + google.protobuf.Timestamp timestamp = 1; // required |
| 93 | + |
| 94 | + // The actual point value. |
| 95 | + oneof value { |
| 96 | + // A 64-bit integer. |
| 97 | + int64 int64_value = 2; |
| 98 | + |
| 99 | + // A 64-bit double-precision floating-point number. |
| 100 | + double double_value = 3; |
| 101 | + |
| 102 | + // TODO: Add support for Summary type. |
| 103 | + } |
| 104 | +} |
| 105 | + |
| 106 | +// Measurements accumulated over a time interval. |
| 107 | +message CumulativePoint { |
| 108 | + // This must be the same until an event resets the cumulative value to zero |
| 109 | + // and sets a new start for the following points. |
| 110 | + google.protobuf.Timestamp start_time = 1; // required |
| 111 | + |
| 112 | + // The end timestamp of the accumulated measurement. |
| 113 | + google.protobuf.Timestamp end_time = 2; // required |
| 114 | + |
| 115 | + // The actual point value. |
| 116 | + oneof value { |
| 117 | + // A 64-bit integer. |
| 118 | + int64 int64_value = 3; |
| 119 | + |
| 120 | + // A 64-bit double-precision floating-point number. |
| 121 | + double double_value = 4; |
| 122 | + |
| 123 | + // A distribution value. |
| 124 | + DistributionValue distribution_value = 5; |
| 125 | + } |
| 126 | +} |
| 127 | + |
| 128 | +// Distribution contains summary statistics for a population of values. It |
| 129 | +// optionally contains a histogram representing the distribution of those |
| 130 | +// values across a set of buckets. |
| 131 | +message DistributionValue { |
| 132 | + // The number of values in the population. Must be non-negative. This value |
| 133 | + // must equal the sum of the values in bucket_counts if a histogram is |
| 134 | + // provided. |
| 135 | + int64 count = 1; |
| 136 | + |
| 137 | + // The arithmetic mean of the values in the population. If count is zero |
| 138 | + // then this field must be zero. |
| 139 | + double mean = 2; |
| 140 | + |
| 141 | + // The sum of squared deviations from the mean of the values in the |
| 142 | + // population. For values x_i this is: |
| 143 | + // |
| 144 | + // Sum[i=1..n]((x_i - mean)^2) |
| 145 | + // |
| 146 | + // Knuth, "The Art of Computer Programming", Vol. 2, page 323, 3rd edition |
| 147 | + // describes Welford's method for accumulating this sum in one pass. |
| 148 | + // |
| 149 | + // If count is zero then this field must be zero. |
| 150 | + double sum_of_squared_deviation = 3; |
| 151 | + |
| 152 | + // The range of the population values. |
| 153 | + message Range { |
| 154 | + // The minimum of the population values. |
| 155 | + double min = 1; |
| 156 | + |
| 157 | + // The maximum of the population values. |
| 158 | + double max = 2; |
| 159 | + } |
| 160 | + |
| 161 | + // If specified, contains the range of the population values. The field |
| 162 | + // must not be present if the count is zero. |
| 163 | + Range range = 4; |
| 164 | + |
| 165 | + // A Distribution may optionally contain a histogram of the values in the |
| 166 | + // population. The bucket boundaries for that histogram are described by |
| 167 | + // bucket_bounds. This defines size(bucket_bounds) + 1 (= N) |
| 168 | + // buckets. The boundaries for bucket index i are: |
| 169 | + // |
| 170 | + // (-infinity, bucket_bounds[i]) for i == 0 |
| 171 | + // [bucket_bounds[i-1], bucket_bounds[i]) for 0 < i < N-2 |
| 172 | + // [bucket_bounds[i-1], +infinity) for i == N-1 |
| 173 | + // |
| 174 | + // i.e. an underflow bucket (number 0), zero or more finite buckets (1 |
| 175 | + // through N - 2, and an overflow bucket (N - 1), with inclusive lower |
| 176 | + // bounds and exclusive upper bounds. |
| 177 | + // |
| 178 | + // If bucket_bounds has no elements (zero size), then there is no |
| 179 | + // histogram associated with the Distribution. If bucket_bounds has only |
| 180 | + // one element, there are no finite buckets, and that single element is the |
| 181 | + // common boundary of the overflow and underflow buckets. The values must |
| 182 | + // be monotonically increasing. |
| 183 | + repeated double bucket_bounds = 5; |
| 184 | + |
| 185 | + message Bucket { |
| 186 | + // The number of values in each bucket of the histogram, as described in |
| 187 | + // bucket_bounds. |
| 188 | + int64 count = 1; |
| 189 | + |
| 190 | + // TODO: Add support for exemplars. |
| 191 | + } |
| 192 | + |
| 193 | + // If the distribution does not have a histogram, then omit this field. |
| 194 | + // If there is a histogram, then the sum of the values in the Bucket counts |
| 195 | + // must equal the value in the count field of the distribution. |
| 196 | + repeated Bucket buckets = 6; |
| 197 | +} |
0 commit comments