Skip to content

Commit bc81641

Browse files
committed
protobuf: Add native histogram support
This is still experimental. It is not clear yet how to represent native histograms in the text format, but with this commit, implementers of OpenMetrics using the protobuf format can already gather experience with native histograms. Signed-off-by: beorn7 <[email protected]>
1 parent da0400b commit bc81641

File tree

1 file changed

+56
-0
lines changed

1 file changed

+56
-0
lines changed

Diff for: proto/openmetrics_data_model.proto

+56
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,62 @@ message HistogramValue {
158158
// Optional.
159159
Exemplar exemplar = 3;
160160
}
161+
162+
// Everything below here is for native histograms (also known as sparse histograms).
163+
164+
// schema defines the bucket schema. Currently, valid numbers are -4 <= n <= 8.
165+
// They are all for base-2 bucket schemas, where 1 is a bucket boundary in each case, and
166+
// then each power of two is divided into 2^n logarithmic buckets.
167+
// Or in other words, each bucket boundary is the previous boundary times 2^(2^-n).
168+
// In the future, more bucket schemas may be added using numbers < -4 or > 8.
169+
// Required.
170+
sint32 schema = 7;
171+
172+
// Breadth of the zero bucket.
173+
// Optional.
174+
double zero_threshold = 8;
175+
176+
// Count in zero bucket.
177+
// Optional.
178+
oneof zero_count {
179+
double double_zero_count = 9;
180+
uint64 int_zero_count = 10;
181+
}
182+
183+
// Negative buckets for the native histogram.
184+
// Optional.
185+
repeated BucketSpan negative_span = 11;
186+
// Use either "negative_delta" or "negative_count", the former for
187+
// regular histograms with integer counts, the latter for float
188+
// histograms.
189+
repeated sint64 negative_delta = 12; // Count delta of each bucket compared to previous one (or to zero for 1st bucket).
190+
repeated double negative_count = 13; // Absolute count of each bucket.
191+
192+
// Positive buckets for the native histogram.
193+
// Optional.
194+
repeated BucketSpan positive_span = 14;
195+
// Use either "positive_delta" or "positive_count", the former for
196+
// regular histograms with integer counts, the latter for float
197+
// histograms.
198+
repeated sint64 positive_delta = 15; // Count delta of each bucket compared to previous one (or to zero for 1st bucket).
199+
repeated double positive_count = 16; // Absolute count of each bucket.
200+
201+
// A BucketSpan defines a number of consecutive buckets in a native
202+
// histogram with their offset. Logically, it would be more
203+
// straightforward to include the bucket counts in the Span. However,
204+
// the protobuf representation is more compact in the way the data is
205+
// structured here (with all the buckets in a single array separate
206+
// from the Spans).
207+
message BucketSpan {
208+
209+
// Gap to previous span, or starting point for 1st span (which can be negative).
210+
// Required.
211+
sint32 offset = 1;
212+
213+
// Length of consecutive buckets.
214+
// Required.
215+
uint32 length = 2;
216+
}
161217
}
162218

163219
message Exemplar {

0 commit comments

Comments
 (0)