mirror of
https://github.com/prometheus/prometheus.git
synced 2026-06-09 00:22:19 -04:00
Merge pull request #18660 from roidelapluie/roidelapluie/histogram-stats-schema
promql: set Schema in HistogramStatsIterator to detect schema mix
This commit is contained in:
commit
4b3323e413
2 changed files with 11 additions and 0 deletions
|
|
@ -86,10 +86,14 @@ func (*HistogramStatsIterator) AtHistogram(*histogram.Histogram) (int64, *histog
|
|||
// performs a counter reset detection on the fly. It will return an explicit
|
||||
// hint (not UnknownCounterReset) if the previous sample has been accessed with
|
||||
// the same iterator.
|
||||
//
|
||||
// The returned histogram contains only Count, Sum, CounterResetHint, and Schema.
|
||||
// Bucket data is intentionally omitted.
|
||||
func (hsi *HistogramStatsIterator) AtFloatHistogram(fh *histogram.FloatHistogram) (int64, *histogram.FloatHistogram) {
|
||||
populateFH := func(src *histogram.FloatHistogram, detectReset bool) {
|
||||
h := histogram.FloatHistogram{
|
||||
CounterResetHint: src.CounterResetHint,
|
||||
Schema: src.Schema,
|
||||
Count: src.Count,
|
||||
Sum: src.Sum,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1118,6 +1118,13 @@ eval instant at 1m30s rate(some_metric[1m30s])
|
|||
expect warn msg: PromQL warning: vector contains a mix of histograms with exponential and custom buckets schemas for metric name "some_metric"
|
||||
# Should produce no results.
|
||||
|
||||
# histogram_count(rate()) must also warn when the schema mix falls inside the stats-only
|
||||
# path (HistogramStatsIterator). Without Schema being set in that iterator, all histograms
|
||||
# appear as Schema=0 and the custom-bucket mismatch is silently missed.
|
||||
eval instant at 1m histogram_count(rate(some_metric[1m30s]))
|
||||
expect warn msg: PromQL warning: vector contains a mix of histograms with exponential and custom buckets schemas for metric name "some_metric"
|
||||
# Should produce no results.
|
||||
|
||||
# Start with custom, end with exponential. Return the exponential histogram divided by 48.
|
||||
# (The 1st sample is the NHCB with count:1. It is mostly ignored with the exception of the
|
||||
# count, which means the rate calculation extrapolates until the count hits 0.)
|
||||
|
|
|
|||
Loading…
Reference in a new issue