(ctx context.Context, from, to model.Time, hints *storage.LabelHints, f func(ctx context.Context, rs ring.ReplicationSet, req *ingester_client.LabelNamesRequest, limiter *limiter.QueryLimiter) ([]any, error), matchers ...*labels.Matcher)
| 1421 | } |
| 1422 | |
| 1423 | func (d *Distributor) LabelNamesCommon(ctx context.Context, from, to model.Time, hints *storage.LabelHints, f func(ctx context.Context, rs ring.ReplicationSet, req *ingester_client.LabelNamesRequest, limiter *limiter.QueryLimiter) ([]any, error), matchers ...*labels.Matcher) ([]string, error) { |
| 1424 | span, ctx := opentracing.StartSpanFromContext(ctx, "Distributor.LabelNames", opentracing.Tags{ |
| 1425 | "start": from.Unix(), |
| 1426 | "end": to.Unix(), |
| 1427 | }) |
| 1428 | defer span.Finish() |
| 1429 | replicationSet, err := d.GetIngestersForMetadata(ctx) |
| 1430 | if err != nil { |
| 1431 | return nil, err |
| 1432 | } |
| 1433 | |
| 1434 | limit := getLimitFromLabelHints(hints) |
| 1435 | req, err := ingester_client.ToLabelNamesRequest(from, to, limit, matchers) |
| 1436 | if err != nil { |
| 1437 | return nil, err |
| 1438 | } |
| 1439 | |
| 1440 | queryLimiter := limiter.QueryLimiterFromContextWithFallback(ctx) |
| 1441 | resps, err := f(ctx, replicationSet, req, queryLimiter) |
| 1442 | if err != nil { |
| 1443 | return nil, err |
| 1444 | } |
| 1445 | |
| 1446 | span, _ = opentracing.StartSpanFromContext(ctx, "response_merge") |
| 1447 | defer span.Finish() |
| 1448 | values := make([][]string, len(resps)) |
| 1449 | for i, resp := range resps { |
| 1450 | values[i] = resp.([]string) |
| 1451 | } |
| 1452 | r, err := util.MergeSlicesParallel(ctx, mergeSlicesParallelism, values...) |
| 1453 | if err != nil { |
| 1454 | return nil, err |
| 1455 | } |
| 1456 | if limit > 0 && len(r) > limit { |
| 1457 | r = r[:limit] |
| 1458 | } |
| 1459 | |
| 1460 | span.SetTag("result_length", len(r)) |
| 1461 | |
| 1462 | return r, nil |
| 1463 | } |
| 1464 | |
| 1465 | func (d *Distributor) LabelNamesStream(ctx context.Context, from, to model.Time, hints *storage.LabelHints, partialDataEnabled bool, matchers ...*labels.Matcher) ([]string, error) { |
| 1466 | return d.LabelNamesCommon(ctx, from, to, hints, func(ctx context.Context, rs ring.ReplicationSet, req *ingester_client.LabelNamesRequest, queryLimiter *limiter.QueryLimiter) ([]any, error) { |
no test coverage detected