Skip to content

Commit 4b803f3

Browse files
committed
Experimental encoding for sparse buckets in histogram
Signed-off-by: beorn7 <beorn@grafana.com>
1 parent 7bc5445 commit 4b803f3

2 files changed

Lines changed: 215 additions & 52 deletions

File tree

go/metrics.pb.go

Lines changed: 200 additions & 52 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

metrics.proto

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,12 @@ message Histogram {
6060
optional uint64 sample_count = 1;
6161
optional double sample_sum = 2;
6262
repeated Bucket bucket = 3; // Ordered in increasing order of upper_bound, +Inf bucket is optional.
63+
// Sparse bucket (sb) stuff:
64+
optional uint32 sb_resolution = 4; // That many buckets per power of ten. Must be <256. Zero for no sparse buckets.
65+
optional double sb_zero_threshold = 5; // Breadth of the zero bucket.
66+
optional uint64 sb_zero_count = 6; // Count in zero bucket.
67+
optional SparseBuckets sb_negative = 7; // Negative sparse buckets.
68+
optional SparseBuckets sb_positive = 8; // Positive sparse buckets.
6369
}
6470

6571
message Bucket {
@@ -68,6 +74,15 @@ message Bucket {
6874
optional Exemplar exemplar = 3;
6975
}
7076

77+
message SparseBuckets {
78+
message Span {
79+
optional sint32 offset = 1; // Gap to previous span, or starting point for 1st span (which can be negative).
80+
optional uint32 length = 2; // Length of consecutive buckets.
81+
}
82+
repeated Span span = 1;
83+
repeated sint64 delta = 2; // Count delta of each bucket compared to previous one (or to zero for 1st bucket).
84+
}
85+
7186
message Exemplar {
7287
repeated LabelPair label = 1;
7388
optional double value = 2;

0 commit comments

Comments
 (0)