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

Method LabelValues

pkg/querier/blocks_store_queryable.go:388–429  ·  view source on GitHub ↗
(ctx context.Context, name string, hints *storage.LabelHints, matchers ...*labels.Matcher)

Source from the content-addressed store, hash-verified

386}
387
388func (q *blocksStoreQuerier) LabelValues(ctx context.Context, name string, hints *storage.LabelHints, matchers ...*labels.Matcher) ([]string, annotations.Annotations, error) {
389 userID, err := users.TenantID(ctx)
390 if err != nil {
391 return nil, nil, err
392 }
393
394 spanLog, spanCtx := spanlogger.New(ctx, "blocksStoreQuerier.LabelValues")
395 defer spanLog.Finish()
396
397 minT, maxT, limit := q.minT, q.maxT, int64(0)
398
399 if hints != nil {
400 limit = int64(hints.Limit)
401 }
402
403 var (
404 resValueSets = [][]string{}
405 resWarnings = annotations.Annotations(nil)
406
407 resultMtx sync.Mutex
408 )
409
410 queryFunc := func(clients map[BlocksStoreClient][]ulid.ULID, minT, maxT int64) ([]ulid.ULID, error, error) {
411 valueSets, warnings, queriedBlocks, err, retryableError := q.fetchLabelValuesFromStore(spanCtx, userID, name, clients, minT, maxT, limit, matchers...)
412 if err != nil {
413 return nil, err, retryableError
414 }
415
416 resultMtx.Lock()
417 resValueSets = append(resValueSets, valueSets...)
418 resWarnings.Merge(warnings)
419 resultMtx.Unlock()
420
421 return queriedBlocks, nil, retryableError
422 }
423
424 if err := q.queryWithConsistencyCheck(spanCtx, spanLog, minT, maxT, matchers, userID, queryFunc); err != nil {
425 return nil, nil, err
426 }
427
428 return strutil.MergeSlices(int(limit), resValueSets...), resWarnings, nil
429}
430
431func (q *blocksStoreQuerier) Close() error {
432 return nil

Callers 1

Calls 6

TenantIDFunction · 0.92
NewFunction · 0.92
FinishMethod · 0.80
MergeMethod · 0.65

Tested by 1