@@ -157,28 +157,94 @@ with standard (exponential) schema (i.e. schemas -4 to 8) and which are
157157of the integer and counter [ flavor] ( https://prometheus.io/docs/specs/native_histograms/#flavors )
158158MUST be converted to an OTLP Exponential Histogram as follows:
159159
160+ - If the Native Histogram ` ResetHint ` (or ` CounterResetHint ` ) indicates gauge
161+ type, the native histogram is dropped. Otherwise this field is ignored.
160162- ` Schema ` is converted to the Exponential Histogram ` Scale ` .
161163- The ` NoRecordedValue ` flag is set to ` true ` if the ` Sum ` is equal to the
162- Stale NaN value. Otherwise,
163- - ` Count ` is converted to Exponential Histogram ` Count ` .
164- - ` Sum ` is converted to the Exponential Histogram ` Sum ` .
164+ [ Stale NaN value] ( https://github.com/prometheus/prometheus/blob/main/model/value/value.go ) .
165+ Otherwise,
166+ - ` Count ` is converted to Exponential Histogram ` Count ` . Note that the ` Count `
167+ may be greater than the sum of all ` Positive ` , ` Negative ` and ` Zero ` bucket
168+ counts in case the Native Histogram observed values outside the IEEE float
169+ range, for example ` -Inf ` , ` +Inf ` , ` NaN ` .
170+ - ` Sum ` is converted to the Exponential Histogram ` Sum ` . Note that the ` Sum `
171+ may be ` NaN ` in case the Native Histogram observed the value ` NaN ` or both
172+ ` -Inf ` and ` +Inf ` . The ` Sum ` may also be ` -Inf ` or ` +Inf ` .
165173- ` Timestamp ` is converted to the Exponential Histogram ` TimeUnixNano ` after
166174 converting milliseconds to nanoseconds.
167175- ` ZeroCount ` is converted directly to the Exponential Histogram ` ZeroCount ` .
168176- ` ZeroThreshold ` , is converted to the Exponential Histogram ` ZeroThreshold ` .
169- - The sparse bucket layout represented by ` PositiveSpans ` and ` PositiveDeltas ` is
170- converted to the Exponential Histogram dense layout represented by ` Positive `
171- bucket counts and ` Offset ` . The same holds for ` NegativeSpans ` and
172- ` NegativeDeltas ` . Note that Prometheus Native Histograms buckets are indexed by
173- upper boundary while Exponential Histograms are indexed by lower boundary, the
174- result being that the Offset fields are different-by-one.
177+ - The [ sparse bucket layout] ( https://prometheus.io/docs/specs/native_histograms/#buckets )
178+ represented by ` PositiveSpans ` and ` PositiveDeltas ` is converted to the
179+ Exponential Histogram dense layout represented by ` Positive ` bucket counts and
180+ ` Offset ` .
181+
182+ - The ` PositiveDeltas ` are delta encoded bucket counts, where the first value
183+ is an absolute bucket count and each subsequent value is a delta to the
184+ previous value.
185+ - The Exponential Histogram ` Positive ` ` Offset ` is set to the first
186+ ` PositiveSpan ` 's ` Offset ` minus 1 (` PositiveSpans[0].Offset-1 ` ) if there
187+ are spans, otherwise left at 0. Note that Prometheus Native Histogram
188+ buckets are indexed by upper boundary while Exponential Histograms are
189+ indexed by lower boundary, hence the minus one.
190+ - The ` PositiveSpans ` encode the index into the ` Positive ` bucket counts for
191+ each value in the ` PositiveDeltas ` . The index starts from 0 for the first
192+ span, for subsequent spans the span's ` Offset ` is added to the previous
193+ index. The span's ` Length ` indicates the number of continuous indexes to
194+ use.
195+ - The Native Histogram may contain overflow buckets. If converted to
196+ an Exponential Histogram bucket, the overflow bucket would map to values
197+ outside the IEEE float range. The Native Histogram SHOULD be dropped in
198+ accordance with [ ExponentialHistogram: Consumer Recommendations] ( ../metrics/data-model.md/#exponentialhistogram-consumer-recommendations ) .
199+ If the Native Histogram is not dropped, the overflow bucket itself MUST be
200+ dropped.
201+
202+ - The ` NegativeSpans ` and ` NegativeDeltas ` are converted the same way as the
203+ positive buckets.
204+ - ` Min ` and ` Max ` are not set.
205+ - ` StartTimeUnixNano ` is set to the ` Start Timestamp ` timestamp, if available.
206+ - ` AggregationTemporality ` is set to ` cumulative ` .
207+
208+ A Native histogram with custom buckets (NHCB) schema (i.e. schema -53) and which
209+ are of the integer and counter [ flavor] ( https://prometheus.io/docs/specs/native_histograms/#flavors )
210+ MUST be converted to an OTLP Histogram as follows:
211+
212+ - If the Native Histogram ` ResetHint ` (or ` CounterResetHint ` ) indicates gauge
213+ type, the native histogram is dropped. Otherwise this field is ignored.
214+ - The ` NoRecordedValue ` flag is set to ` true ` if the ` Sum ` is equal to the
215+ [ Stale NaN value] ( https://github.com/prometheus/prometheus/blob/main/model/value/value.go ) .
216+ Otherwise,
217+ - ` Count ` is converted to Histogram ` Count ` . Note that the ` Count `
218+ is equal to the sum of all bucket counts.
219+ - ` Sum ` is converted to the Histogram ` Sum ` . Note that the ` Sum `
220+ may be ` NaN ` in case the Native Histogram observed the value ` NaN ` or both
221+ ` -Inf ` and ` +Inf ` . The ` Sum ` may also be ` -Inf ` or ` +Inf ` .
222+ - ` Timestamp ` is converted to the Histogram ` TimeUnixNano ` after
223+ converting milliseconds to nanoseconds.
175224- ` Min ` and ` Max ` are not set.
176- - ` StartTimeUnixNano ` is set to the ` Created ` timestamp, if available.
225+ - [ ` CustomValues ` ] ( https://prometheus.io/docs/specs/native_histograms/#custom-values )
226+ is converted to bucket boundaries. The ` +Inf ` bucket is implicit, therefore
227+ ` N ` ` CustomValues ` represent ` N+1 ` Histogram bucket counts.
228+ - The [ sparse bucket layout] ( https://prometheus.io/docs/specs/native_histograms/#buckets )
229+ represented by ` PositiveSpans ` and ` PositiveDeltas ` is converted to
230+ Histogram bucket counts.
231+
232+ - The ` PositiveDeltas ` are delta encoded bucket counts, where the first value
233+ is an absolute bucket count and each subsequent value is a delta to the
234+ previous value.
235+ - The ` PositiveSpans ` encode the index into the bucket counts for each value
236+ in the ` PositiveDeltas ` . The index starts from the ` Offset ` in the first
237+ span and for subsequent spans the span's ` Offset ` is added to the previous
238+ index. The span's ` Length ` indicates the number of continuous indexes to
239+ use.
240+
241+ - ` StartTimeUnixNano ` is set to the ` Start Timestamp ` , if available.
177242- ` AggregationTemporality ` is set to ` cumulative ` .
178243
179244Native histograms of the float or gauge flavors MUST be dropped.
180245
181- Native Histograms with ` Schema ` outside of the range [ -4, 8] MUST be dropped.
246+ Native Histograms with ` Schema ` outside of the range [ -4, 8] and not equal to
247+ -53 MUST be dropped.
182248
183249### Summaries
184250
0 commit comments