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

Method SearchBlock

modules/querier/querier.go:615–668  ·  view source on GitHub ↗

SearchBlock searches the specified subset of the block for the passed tags.

(ctx context.Context, req *tempopb.SearchBlockRequest)

Source from the content-addressed store, hash-verified

613
614// SearchBlock searches the specified subset of the block for the passed tags.
615func (q *Querier) SearchBlock(ctx context.Context, req *tempopb.SearchBlockRequest) (*tempopb.SearchResponse, error) {
616 tenantID, err := validation.ExtractValidTenantID(ctx)
617 if err != nil {
618 return nil, fmt.Errorf("error extracting org id in Querier.BackendSearch: %w", err)
619 }
620
621 blockID, err := backend.ParseUUID(req.BlockID)
622 if err != nil {
623 return nil, err
624 }
625
626 dc, err := backend.DedicatedColumnsFromTempopb(req.DedicatedColumns)
627 if err != nil {
628 return nil, err
629 }
630
631 meta := &backend.BlockMeta{
632 Version: req.Version,
633 TenantID: tenantID,
634 Size_: req.Size_,
635 IndexPageSize: req.IndexPageSize,
636 TotalRecords: req.TotalRecords,
637 BlockID: blockID,
638 FooterSize: req.FooterSize,
639 DedicatedColumns: dc,
640 }
641
642 opts := common.DefaultSearchOptions()
643 opts.StartPage = int(req.StartPage)
644 opts.TotalPages = int(req.PagesToSearch)
645 opts.MaxBytes = q.limits.MaxBytesPerTrace(tenantID)
646
647 if api.IsTraceQLQuery(req.SearchReq) {
648 fetcher := traceql.NewSpansetFetcherWrapperBoth(
649 func(ctx context.Context, req traceql.FetchSpansRequest) (traceql.FetchSpansResponse, error) {
650 return q.store.Fetch(ctx, meta, req, opts)
651 },
652 func(ctx context.Context, req traceql.FetchSpansRequest) (traceql.FetchSpansOnlyResponse, error) {
653 return q.store.FetchSpans(ctx, meta, req, opts)
654 },
655 )
656
657 var compileOpts []traceql.CompileOption
658 if q.limits.UnsafeQueryHints(tenantID) {
659 compileOpts = append(compileOpts, traceql.WithUnsafeHints(true))
660 }
661 for _, name := range req.SearchReq.SkipASTTransformations {
662 compileOpts = append(compileOpts, traceql.WithSkipOptimization(name))
663 }
664 return q.engine.ExecuteSearch(ctx, req.SearchReq, fetcher, compileOpts...)
665 }
666
667 return q.store.Search(ctx, meta, req.SearchReq, opts)
668}
669
670func (q *Querier) internalTagsSearchBlockV2(ctx context.Context, req *tempopb.SearchTagsBlockRequest) (*tempopb.SearchTagsV2Response, error) {
671 // For the intrinsic scope there is nothing to do in the querier,

Callers 1

SearchHandlerMethod · 0.95

Calls 14

ExtractValidTenantIDFunction · 0.92
ParseUUIDFunction · 0.92
DefaultSearchOptionsFunction · 0.92
IsTraceQLQueryFunction · 0.92
WithUnsafeHintsFunction · 0.92
WithSkipOptimizationFunction · 0.92
ExecuteSearchMethod · 0.80
MaxBytesPerTraceMethod · 0.65
FetchMethod · 0.65
FetchSpansMethod · 0.65

Tested by

no test coverage detected