(ctx context.Context, id common.ID, opts common.SearchOptions)
| 542 | } |
| 543 | |
| 544 | func (b *walBlock) FindTraceByID(ctx context.Context, id common.ID, opts common.SearchOptions) (*tempopb.TraceByIDResponse, error) { |
| 545 | ctx, span := tracer.Start(ctx, "walBlock.FindTraceByID") |
| 546 | defer span.End() |
| 547 | |
| 548 | metrics := &tempopb.TraceByIDMetrics{} |
| 549 | trs := make([]*tempopb.Trace, 0) |
| 550 | |
| 551 | for _, page := range b.readFlushes() { |
| 552 | if rowNumber, ok := page.ids.Get(id); ok { |
| 553 | file, err := page.file(ctx) |
| 554 | if err != nil { |
| 555 | return nil, fmt.Errorf("error opening file %s: %w", page.path, err) |
| 556 | } |
| 557 | |
| 558 | defer file.Close() |
| 559 | pf := file.parquetFile |
| 560 | |
| 561 | r := parquet.NewReader(pf) |
| 562 | defer r.Close() |
| 563 | |
| 564 | err = r.SeekToRow(rowNumber) |
| 565 | if err != nil { |
| 566 | return nil, fmt.Errorf("seek to row: %w", err) |
| 567 | } |
| 568 | |
| 569 | tr := new(Trace) |
| 570 | err = r.Read(tr) |
| 571 | if err != nil { |
| 572 | return nil, fmt.Errorf("error reading row from backend: %w", err) |
| 573 | } |
| 574 | |
| 575 | trp := ParquetTraceToTempopbTrace(b.meta, tr) |
| 576 | |
| 577 | trs = append(trs, trp) |
| 578 | |
| 579 | metrics.InspectedBytes += file.r.BytesRead() |
| 580 | } |
| 581 | } |
| 582 | |
| 583 | combiner := trace.NewCombiner(opts.MaxBytes, false) |
| 584 | for i, tr := range trs { |
| 585 | _, err := combiner.ConsumeWithFinal(tr, i == len(trs)-1) |
| 586 | if err != nil { |
| 587 | return nil, err |
| 588 | } |
| 589 | } |
| 590 | |
| 591 | tr, _ := combiner.Result() |
| 592 | response := &tempopb.TraceByIDResponse{ |
| 593 | Trace: tr, |
| 594 | Metrics: metrics, |
| 595 | } |
| 596 | return response, nil |
| 597 | } |
| 598 | |
| 599 | func (b *walBlock) Search(ctx context.Context, req *tempopb.SearchRequest, _ common.SearchOptions) (*tempopb.SearchResponse, error) { |
| 600 | ctx, span := tracer.Start(ctx, "walBlock.Search") |
nothing calls this directly
no test coverage detected