MCPcopy
hub / github.com/grafana/tempo / SearchTagValuesV2

Method SearchTagValuesV2

tempodb/tempodb.go:499–532  ·  view source on GitHub ↗
(ctx context.Context, meta *backend.BlockMeta, req *tempopb.SearchTagValuesRequest, opts common.SearchOptions)

Source from the content-addressed store, hash-verified

497}
498
499func (rw *readerWriter) SearchTagValuesV2(ctx context.Context, meta *backend.BlockMeta, req *tempopb.SearchTagValuesRequest, opts common.SearchOptions) (*tempopb.SearchTagValuesV2Response, error) {
500 block, err := encoding.OpenBlock(meta, rw.r)
501 if err != nil {
502 return nil, err
503 }
504
505 tag, err := traceql.ParseIdentifier(req.TagName)
506 if err != nil {
507 return nil, err
508 }
509
510 dv := collector.NewDistinctValue(0, req.MaxTagValues, req.StaleValueThreshold, func(v tempopb.TagValue) int { return len(v.Type) + len(v.Value) })
511 mc := collector.NewMetricsCollector()
512 rw.cfg.Search.ApplyToOptions(&opts)
513 err = block.SearchTagValuesV2(ctx, tag, traceql.MakeCollectTagValueFunc(dv.Collect), mc.Add, opts)
514 if err != nil {
515 return nil, err
516 }
517
518 orgID, _ := user.ExtractOrgID(ctx)
519 if dv.Exceeded() {
520 level.Warn(log.Logger).Log("msg", "Search tags exceeded limit, reduce cardinality or size of tags", "orgID", orgID, "stopReason", dv.StopReason())
521 }
522
523 resp := &tempopb.SearchTagValuesV2Response{
524 Metrics: &tempopb.MetadataMetrics{InspectedBytes: mc.TotalValue()},
525 }
526 for _, v := range dv.Values() {
527 v2 := v
528 resp.TagValues = append(resp.TagValues, &v2)
529 }
530
531 return resp, nil
532}
533
534// Fetch only uses rw.r which has caching enabled
535func (rw *readerWriter) Fetch(ctx context.Context, meta *backend.BlockMeta, req traceql.FetchSpansRequest, opts common.SearchOptions) (traceql.FetchSpansResponse, error) {

Callers

nothing calls this directly

Calls 12

TotalValueMethod · 0.95
OpenBlockFunction · 0.92
ParseIdentifierFunction · 0.92
NewDistinctValueFunction · 0.92
NewMetricsCollectorFunction · 0.92
MakeCollectTagValueFuncFunction · 0.92
ApplyToOptionsMethod · 0.80
SearchTagValuesV2Method · 0.65
LogMethod · 0.65
ExceededMethod · 0.45
StopReasonMethod · 0.45
ValuesMethod · 0.45

Tested by

no test coverage detected