MCPcopy Create free account
hub / github.com/cortexproject/cortex / LabelNames

Method LabelNames

pkg/querier/distributor_queryable.go:265–296  ·  view source on GitHub ↗
(ctx context.Context, hints *storage.LabelHints, matchers ...*labels.Matcher)

Source from the content-addressed store, hash-verified

263}
264
265func (q *distributorQuerier) LabelNames(ctx context.Context, hints *storage.LabelHints, matchers ...*labels.Matcher) ([]string, annotations.Annotations, error) {
266 partialDataEnabled := q.partialDataEnabled(ctx)
267
268 if len(matchers) > 0 && !q.labelNamesMatchers {
269 return q.labelNamesWithMatchers(ctx, hints, partialDataEnabled, matchers...)
270 }
271
272 log, ctx := spanlogger.New(ctx, "distributorQuerier.LabelNames")
273 defer log.Finish()
274
275 var (
276 ln []string
277 err error
278 )
279
280 if q.streamingMetadata {
281 ln, err = q.labelsWithRetry(ctx, func() ([]string, error) {
282 return q.distributor.LabelNamesStream(ctx, model.Time(q.mint), model.Time(q.maxt), hints, partialDataEnabled, matchers...)
283 })
284 } else {
285 ln, err = q.labelsWithRetry(ctx, func() ([]string, error) {
286 return q.distributor.LabelNames(ctx, model.Time(q.mint), model.Time(q.maxt), hints, partialDataEnabled, matchers...)
287 })
288 }
289
290 if partialdata.IsPartialDataError(err) {
291 warnings := annotations.Annotations(nil)
292 return ln, warnings.Add(err), nil
293 }
294
295 return ln, nil, err
296}
297
298func (q *distributorQuerier) labelsWithRetry(ctx context.Context, labelsFunc func() ([]string, error)) ([]string, error) {
299 if q.ingesterQueryMaxAttempts <= 1 {

Callers

nothing calls this directly

Calls 9

partialDataEnabledMethod · 0.95
labelsWithRetryMethod · 0.95
NewFunction · 0.92
IsPartialDataErrorFunction · 0.92
FinishMethod · 0.80
LabelNamesStreamMethod · 0.65
LabelNamesMethod · 0.65
AddMethod · 0.45

Tested by

no test coverage detected