(ctx context.Context, req *tempopb.SearchTagValuesRequest)
| 500 | } |
| 501 | |
| 502 | func (q *Querier) SearchTagValues(ctx context.Context, req *tempopb.SearchTagValuesRequest) (*tempopb.SearchTagValuesResponse, error) { |
| 503 | userID, err := validation.ExtractValidTenantID(ctx) |
| 504 | if err != nil { |
| 505 | return nil, fmt.Errorf("error extracting org id in Querier.SearchTagValues: %w", err) |
| 506 | } |
| 507 | |
| 508 | maxDataSize := q.limits.MaxBytesPerTagValuesQuery(userID) |
| 509 | distinctValues := collector.NewDistinctString(maxDataSize, req.MaxTagValues, req.StaleValueThreshold) |
| 510 | var inspectedBytes uint64 |
| 511 | |
| 512 | // Virtual tags values. Get these first. |
| 513 | for _, v := range search.GetVirtualTagValues(req.TagName) { |
| 514 | // virtual tags are small so no need to stop early here |
| 515 | distinctValues.Collect(v) |
| 516 | } |
| 517 | |
| 518 | results, err := q.forLiveStoreRing(ctx, func(ctx context.Context, client tempopb.QuerierClient) (any, error) { |
| 519 | return client.SearchTagValues(ctx, req) |
| 520 | }) |
| 521 | if err != nil { |
| 522 | return nil, fmt.Errorf("error querying live-stores in Querier.SearchTagValues: %w", err) |
| 523 | } |
| 524 | |
| 525 | outer: |
| 526 | for _, result := range results { |
| 527 | resp := result.(*tempopb.SearchTagValuesResponse) |
| 528 | if resp.Metrics != nil { |
| 529 | inspectedBytes += resp.Metrics.InspectedBytes |
| 530 | } |
| 531 | |
| 532 | for _, res := range resp.TagValues { |
| 533 | distinctValues.Collect(res) |
| 534 | if distinctValues.Exceeded() { |
| 535 | break outer |
| 536 | } |
| 537 | } |
| 538 | } |
| 539 | |
| 540 | if distinctValues.Exceeded() { |
| 541 | level.Warn(log.Logger).Log("msg", "Search of tag values exceeded limit, reduce cardinality or size of tags", "tag", req.TagName, "orgID", userID, "stopReason", distinctValues.StopReason()) |
| 542 | } |
| 543 | |
| 544 | return &tempopb.SearchTagValuesResponse{ |
| 545 | TagValues: distinctValues.Strings(), |
| 546 | Metrics: &tempopb.MetadataMetrics{InspectedBytes: inspectedBytes}, |
| 547 | }, nil |
| 548 | } |
| 549 | |
| 550 | func (q *Querier) SearchTagValuesV2(ctx context.Context, req *tempopb.SearchTagValuesRequest) (*tempopb.SearchTagValuesV2Response, error) { |
| 551 | userID, err := validation.ExtractValidTenantID(ctx) |
no test coverage detected