MCPcopy
hub / github.com/prometheus/prometheus / SearchLabelValues

Method SearchLabelValues

tsdb/querier.go:110–140  ·  view source on GitHub ↗

SearchLabelValues implements storage.Searcher.

(ctx context.Context, name string, hints *storage.SearchHints, matchers ...*labels.Matcher)

Source from the content-addressed store, hash-verified

108
109// SearchLabelValues implements storage.Searcher.
110func (q *blockBaseQuerier) SearchLabelValues(ctx context.Context, name string, hints *storage.SearchHints, matchers ...*labels.Matcher) storage.SearchResultSet {
111 if hints == nil {
112 hints = &storage.SearchHints{}
113 }
114
115 // Limit pushdown is only correct when natural (ascending) index order
116 // is preserved all the way to the output and no filtering discards
117 // values ahead of the limit.
118 labelHints := &storage.LabelHints{}
119 if hints.OrderBy == storage.OrderByValueAsc && hints.Filter == nil {
120 labelHints.Limit = hints.Limit
121 }
122
123 var (
124 values []string
125 err error
126 )
127 switch hints.OrderBy {
128 case storage.OrderByScoreDesc:
129 // Score-based sorting happens in ApplySearchHints; avoid the
130 // index-level sort.
131 values, err = q.index.LabelValues(ctx, name, labelHints, matchers...)
132 default:
133 values, err = q.index.SortedLabelValues(ctx, name, labelHints, matchers...)
134 }
135 if err != nil {
136 return storage.ErrSearchResultSet(err)
137 }
138
139 return storage.NewSearchResultSetFromSlice(storage.ApplySearchHints(values, hints), nil)
140}
141
142func (q *blockBaseQuerier) Close() error {
143 if q.closed {

Callers

nothing calls this directly

Calls 5

ErrSearchResultSetFunction · 0.92
ApplySearchHintsFunction · 0.92
LabelValuesMethod · 0.65
SortedLabelValuesMethod · 0.65

Tested by

no test coverage detected