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

Method Fetch

tempodb/encoding/vparquet3/wal_block.go:663–706  ·  view source on GitHub ↗
(ctx context.Context, req traceql.FetchSpansRequest, _ common.SearchOptions)

Source from the content-addressed store, hash-verified

661}
662
663func (b *walBlock) Fetch(ctx context.Context, req traceql.FetchSpansRequest, _ common.SearchOptions) (traceql.FetchSpansResponse, error) {
664 // todo: this same method is called in backendBlock.Fetch. is there anyway to share this?
665 err := checkConditions(req.Conditions)
666 if err != nil {
667 return traceql.FetchSpansResponse{}, fmt.Errorf("conditions invalid: %w", err)
668 }
669
670 blockFlushes := b.readFlushes()
671 // collect page readers to compute totalBytesRead
672 readers := make([]*walReaderAt, 0, len(blockFlushes))
673 iters := make([]traceql.SpansetIterator, 0, len(blockFlushes))
674 for _, page := range blockFlushes {
675 file, err := page.file(ctx)
676 if err != nil {
677 return traceql.FetchSpansResponse{}, fmt.Errorf("error opening file %s: %w", page.path, err)
678 }
679
680 pf := file.parquetFile
681
682 iter, err := fetch(ctx, req, pf, pf.RowGroups(), b.meta.DedicatedColumns)
683 if err != nil {
684 return traceql.FetchSpansResponse{}, fmt.Errorf("creating fetch iter: %w", err)
685 }
686
687 wrappedIterator := &pageFileClosingIterator{iter: iter, pageFile: file}
688 iters = append(iters, wrappedIterator)
689 readers = append(readers, file.r)
690 }
691
692 // combine iters?
693 return traceql.FetchSpansResponse{
694 Results: &mergeSpansetIterator{
695 iters: iters,
696 },
697 Bytes: func() uint64 {
698 // read value when callback is called
699 var totalBytesRead uint64
700 for _, r := range readers {
701 totalBytesRead += r.BytesRead()
702 }
703 return totalBytesRead
704 },
705 }, nil
706}
707
708func (b *walBlock) FetchSpans(_ context.Context, _ traceql.FetchSpansRequest, _ common.SearchOptions) (traceql.FetchSpansOnlyResponse, error) {
709 return traceql.FetchSpansOnlyResponse{}, util.ErrUnsupported

Callers

nothing calls this directly

Calls 5

readFlushesMethod · 0.95
checkConditionsFunction · 0.70
fetchFunction · 0.70
fileMethod · 0.45
BytesReadMethod · 0.45

Tested by

no test coverage detected