mirror of
https://github.com/prometheus/prometheus.git
synced 2026-06-09 08:32:26 -04:00
promql: set Schema in HistogramStatsIterator to detect schema mix
Without Schema being propagated in HistogramStatsIterator, histograms served through the stats-only path (e.g. histogram_count(rate(...))) all appear as Schema=0, causing the exponential/custom-bucket mismatch detection to be silently skipped. Add a test that exercises histogram_count(rate()) over a series with mixed exponential and custom bucket schemas to verify the warning is emitted. Signed-off-by: Julien Pivotto <291750+roidelapluie@users.noreply.github.com>
This commit is contained in:
parent
ecab2f45a8
commit
51d7f024dd
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