(ctx context.Context, id common.ID, opts common.SearchOptions)
| 557 | } |
| 558 | |
| 559 | func (b *walBlock) FindTraceByID(ctx context.Context, id common.ID, opts common.SearchOptions) (*tempopb.TraceByIDResponse, error) { |
| 560 | ctx, span := tracer.Start(ctx, "walBlock.FindTraceByID") |
| 561 | defer span.End() |
| 562 | |
| 563 | metrics := &tempopb.TraceByIDMetrics{} |
| 564 | trs := make([]*tempopb.Trace, 0) |
| 565 | |
| 566 | for _, page := range b.readFlushes() { |
| 567 | if rowNumber, ok := page.ids.Get(id); ok { |
| 568 | file, err := page.file(ctx) |
| 569 | if err != nil { |
| 570 | return nil, fmt.Errorf("error opening file %s: %w", page.path, err) |
| 571 | } |
| 572 | |
| 573 | defer file.Close() |
| 574 | pf := file.parquetFile |
| 575 | |
| 576 | _, _, readerOptions := SchemaWithDynamicChanges(page.dedcols) |
| 577 | |
| 578 | r := parquet.NewGenericReader[*Trace](pf, readerOptions...) |
| 579 | defer r.Close() |
| 580 | |
| 581 | err = r.SeekToRow(rowNumber) |
| 582 | if err != nil { |
| 583 | return nil, fmt.Errorf("seek to row: %w", err) |
| 584 | } |
| 585 | |
| 586 | tr := new(Trace) |
| 587 | n, err := r.Read([]*Trace{tr}) |
| 588 | if n == 0 || (err != nil && !errors.Is(err, io.EOF)) { |
| 589 | return nil, fmt.Errorf("error reading row from backend: %w", err) |
| 590 | } |
| 591 | |
| 592 | trp := ParquetTraceToTempopbTrace(b.meta, tr) |
| 593 | |
| 594 | trs = append(trs, trp) |
| 595 | |
| 596 | metrics.InspectedBytes += file.r.BytesRead() |
| 597 | } |
| 598 | } |
| 599 | |
| 600 | combiner := trace.NewCombiner(opts.MaxBytes, false) |
| 601 | for i, tr := range trs { |
| 602 | _, err := combiner.ConsumeWithFinal(tr, i == len(trs)-1) |
| 603 | if err != nil { |
| 604 | return nil, err |
| 605 | } |
| 606 | } |
| 607 | |
| 608 | tr, _ := combiner.Result() |
| 609 | response := &tempopb.TraceByIDResponse{ |
| 610 | Trace: tr, |
| 611 | Metrics: metrics, |
| 612 | } |
| 613 | return response, nil |
| 614 | } |
| 615 | |
| 616 | func (b *walBlock) Search(ctx context.Context, req *tempopb.SearchRequest, _ common.SearchOptions) (*tempopb.SearchResponse, error) { |
nothing calls this directly
no test coverage detected