mirror of
https://github.com/prometheus/prometheus.git
synced 2025-03-05 20:59:13 -08:00
TSDB: Fix up LabelValues to work for OOO-only head
Signed-off-by: Bryan Boreham <bjboreham@gmail.com>
This commit is contained in:
parent
6529d6336c
commit
f261597944
|
@ -627,6 +627,20 @@ func (oh *HeadAndOOOIndexReader) Series(ref storage.SeriesRef, builder *labels.S
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// LabelValues needs to be overridden from the headIndexReader implementation
|
||||||
|
// so we can return labels within either in-order range or ooo range.
|
||||||
|
func (oh *HeadAndOOOIndexReader) LabelValues(ctx context.Context, name string, matchers ...*labels.Matcher) ([]string, error) {
|
||||||
|
if oh.maxt < oh.head.MinTime() && oh.maxt < oh.head.MinOOOTime() || oh.mint > oh.head.MaxTime() && oh.mint > oh.head.MaxOOOTime() {
|
||||||
|
return []string{}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(matchers) == 0 {
|
||||||
|
return oh.head.postings.LabelValues(ctx, name), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
return labelValuesWithMatchers(ctx, oh, name, matchers...)
|
||||||
|
}
|
||||||
|
|
||||||
type HeadAndOOOChunkReader struct {
|
type HeadAndOOOChunkReader struct {
|
||||||
head *Head
|
head *Head
|
||||||
mint, maxt int64
|
mint, maxt int64
|
||||||
|
|
|
@ -421,17 +421,17 @@ func testOOOHeadChunkReader_LabelValues(t *testing.T, scenario sampleTypeScenari
|
||||||
name: "LabelValues calls with ooo head query range not overlapping out-of-order data",
|
name: "LabelValues calls with ooo head query range not overlapping out-of-order data",
|
||||||
queryMinT: 100,
|
queryMinT: 100,
|
||||||
queryMaxT: 100,
|
queryMaxT: 100,
|
||||||
expValues1: []string{},
|
expValues1: []string{"bar1"},
|
||||||
expValues2: []string{},
|
expValues2: nil,
|
||||||
expValues3: []string{},
|
expValues3: []string{"bar1", "bar2"},
|
||||||
expValues4: []string{},
|
expValues4: []string{"bar1", "bar2"},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, tc := range cases {
|
for _, tc := range cases {
|
||||||
t.Run(tc.name, func(t *testing.T) {
|
t.Run(tc.name, func(t *testing.T) {
|
||||||
// We first want to test using a head index reader that covers the biggest query interval
|
// We first want to test using a head index reader that covers the biggest query interval
|
||||||
oh := NewOOOHeadIndexReader(head, tc.queryMinT, tc.queryMaxT, 0)
|
oh := NewHeadAndOOOIndexReader(head, tc.queryMinT, tc.queryMaxT, 0)
|
||||||
matchers := []*labels.Matcher{labels.MustNewMatcher(labels.MatchEqual, "foo", "bar1")}
|
matchers := []*labels.Matcher{labels.MustNewMatcher(labels.MatchEqual, "foo", "bar1")}
|
||||||
values, err := oh.LabelValues(ctx, "foo", matchers...)
|
values, err := oh.LabelValues(ctx, "foo", matchers...)
|
||||||
sort.Strings(values)
|
sort.Strings(values)
|
||||||
|
|
Loading…
Reference in a new issue