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

Method LabelNames

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

Source from the content-addressed store, hash-verified

343}
344
345func (q *blocksStoreQuerier) LabelNames(ctx context.Context, hints *storage.LabelHints, matchers ...*labels.Matcher) ([]string, annotations.Annotations, error) {
346 userID, err := users.TenantID(ctx)
347 if err != nil {
348 return nil, nil, err
349 }
350
351 spanLog, spanCtx := spanlogger.New(ctx, "blocksStoreQuerier.LabelNames")
352 defer spanLog.Finish()
353
354 minT, maxT, limit := q.minT, q.maxT, int64(0)
355
356 if hints != nil {
357 limit = int64(hints.Limit)
358 }
359
360 var (
361 resMtx sync.Mutex
362 resNameSets = [][]string{}
363 resWarnings = annotations.Annotations(nil)
364 convertedMatchers = convertMatchersToLabelMatcher(matchers)
365 )
366
367 queryFunc := func(clients map[BlocksStoreClient][]ulid.ULID, minT, maxT int64) ([]ulid.ULID, error, error) {
368 nameSets, warnings, queriedBlocks, err, retryableError := q.fetchLabelNamesFromStore(spanCtx, userID, clients, minT, maxT, limit, convertedMatchers)
369 if err != nil {
370 return nil, err, retryableError
371 }
372
373 resMtx.Lock()
374 resNameSets = append(resNameSets, nameSets...)
375 resWarnings.Merge(warnings)
376 resMtx.Unlock()
377
378 return queriedBlocks, nil, retryableError
379 }
380
381 if err := q.queryWithConsistencyCheck(spanCtx, spanLog, minT, maxT, matchers, userID, queryFunc); err != nil {
382 return nil, nil, err
383 }
384
385 return strutil.MergeSlices(int(limit), resNameSets...), resWarnings, nil
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)

Callers 1

Calls 7

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

Tested by 1