Skip to content

Commit 0ef8516

Browse files
committed
Update proposal with the results of the design doc
Signed-off-by: Chris Marchbanks <[email protected]>
1 parent 6ce4170 commit 0ef8516

File tree

1 file changed

+30
-7
lines changed

1 file changed

+30
-7
lines changed

Diff for: proposals/2024-01-29_native_histograms_text_format.md

+30-7
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* **Implementation Status:** Not implemented
77

88
* **Related Issues and PRs:**
9-
* `<GH Issues/PRs>`
9+
* [Native Histogram Support in client_python](https://github.com/prometheus/client_python/issues/918)
1010

1111
* **Other docs or links:**
1212
* [Design Doc for choosing a proposal](https://docs.google.com/document/d/1qoHf24cKMpa1QHskIjgzyf3oFhIPvacyJj8Tbe6fIrY/edit#heading=h.5sybau7waq2q)
@@ -19,8 +19,6 @@ Today it is only possible to export native histograms using the Protocol Buffers
1919

2020
During a [dev summit in 2022](https://docs.google.com/document/d/11LC3wJcVk00l8w5P3oLQ-m3Y37iom6INAMEu2ZAGIIE/edit#bookmark=id.c3e7ur6rn5d2) there was consensus we would continue to support the text format. Including native histograms as part of the text format shows commitment to that consensus.
2121

22-
See the linked design doc in Google Docs for additional background information.
23-
2422
### Pitfalls of the current solution
2523

2624
Prometheus client libraries such as Python do not want to require a dependency on protobuf in order to expose native histograms, and in some languages protobuf is painful to use. Gating native histograms only to clients/users willing to use protobuf hurts adoption of native histograms, therefore, we would like a way to represent a native histogram in the text based format.
@@ -46,15 +44,40 @@ Client library maintainers, OpenMetrics, and Prometheus scrape maintainers.
4644

4745
## How
4846

49-
To be filled out after one of the proposals in the linked design doc has support.
47+
Extend the OpenMetrics text format to allow structured values instead of only float values. This structured value will be used to encode a structure with the same fields as is exposed using the protobuf exposition format. Starting with an example and then breaking up the format:
48+
```
49+
# TYPE nativehistogram histogram
50+
nativehistogram {sample_count:24,sample_sum:100,schema:0,zero_threshold:0.001,zero_count:4,positive_span:[0:2,1:2],negative_span:[0:2,1:2],positive_delta:[2,1,-2,3],negative_delta:[2,1,-2,3]}
51+
```
52+
The metric will have no "magic" suffixes, then the value for each series is a custom struct format with the following fields:
53+
* `sum: float64` - The sum of all observations for this histogram. Could be negative in cases with negative observations.
54+
* `count: uint64` - The number of samples that were observed for this histogram.
55+
* `schema: int32` - The schema used for this histogram, currently supported values are -4 -> 8.
56+
* `zero_threshold: float64` - The width of the zero bucket.
57+
* `zero_count: uint64` - The number of observations inside the zero bucket.
58+
* `negative_span: []BucketSpan` - The buckets corresponding to negative observations, optional.
59+
* `negative_delta: []int64` - The delta of counts compared to the previous bucket.
60+
* `positive_span: []BucketSpan` - The buckets corresponding to negative observations, optional.
61+
* `positive_delta: []int64` - The delta of counts compared to the previous bucket.
62+
63+
A bucket span is the combination of an `int32` offset and a `uint32` length. It is encoded as `<offset>:<length>`. Lists/arrays are encoded within square brackets with elements separated by commas. Compared to JSON this avoids consistently repeating keys and curly braces.
64+
65+
Note that in this initial implementation float histograms are not supported.
5066

5167
## Alternatives
5268

53-
To be filled out after one of the proposals in the linked design doc has support.
69+
### Do nothing
70+
71+
One valid option is to avoid this extra format and require anyone who desires to use native histograms to use protobuf for exposition. It would go against the consensus of the Prometheus team members from 2022 however.
72+
73+
### Alternate exposition formats
74+
75+
See the alternate exposition formats proposed in the [design document](https://docs.google.com/document/d/1qoHf24cKMpa1QHskIjgzyf3oFhIPvacyJj8Tbe6fIrY/edit#heading=h.5sybau7waq2q). The other formats generally added in additional readability/verbosity at the expense of performance.
5476

5577
## Action Plan
5678

5779
The tasks to do in order to migrate to the new idea.
5880

59-
* [ ] Task one <GH issue>
60-
* [ ] Task two <GH issue> ...
81+
* [ ] Implement an encoder and parser in client_python
82+
* [ ] Implement an experimental parser in the Prometheus server
83+
* [ ] Update OpenMetrics with formalized syntax

0 commit comments

Comments
 (0)