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

Method FindTraceByID

tempodb/encoding/vparquet4/block_findtracebyid.go:103–144  ·  view source on GitHub ↗
(ctx context.Context, traceID common.ID, opts common.SearchOptions)

Source from the content-addressed store, hash-verified

101}
102
103func (b *backendBlock) FindTraceByID(ctx context.Context, traceID common.ID, opts common.SearchOptions) (_ *tempopb.TraceByIDResponse, err error) {
104 derivedCtx, span := tracer.Start(ctx, "parquet.backendBlock.FindTraceByID",
105 trace.WithAttributes(
106 attribute.String("blockID", b.meta.BlockID.String()),
107 attribute.String("tenantID", b.meta.TenantID),
108 attribute.Int64("blockSize", int64(b.meta.Size_)),
109 ))
110 defer span.End()
111
112 found, err := b.checkBloom(derivedCtx, traceID)
113 if err != nil {
114 return nil, err
115 }
116 if !found {
117 return nil, nil
118 }
119
120 ok, rowGroup, err := b.checkIndex(derivedCtx, traceID)
121 if err != nil {
122 return nil, err
123 }
124 if !ok {
125 return nil, nil
126 }
127
128 pf, rr, err := b.openForSearch(derivedCtx, opts)
129 if err != nil {
130 return nil, fmt.Errorf("unexpected error opening parquet file: %w", err)
131 }
132
133 foundTrace, err := findTraceByID(derivedCtx, traceID, b.meta, pf, rowGroup)
134
135 result := &tempopb.TraceByIDResponse{
136 Trace: foundTrace,
137 Metrics: &tempopb.TraceByIDMetrics{},
138 }
139 bytesRead := rr.BytesRead()
140 result.Metrics.InspectedBytes += bytesRead
141 span.SetAttributes(attribute.Int64("inspectedBytes", int64(bytesRead)))
142
143 return result, err
144}
145
146func findTraceByID(ctx context.Context, traceID common.ID, meta *backend.BlockMeta, pf *parquet.File, rowGroup int) (*tempopb.Trace, error) {
147 // traceID column index

Callers

nothing calls this directly

Calls 7

checkBloomMethod · 0.95
checkIndexMethod · 0.95
openForSearchMethod · 0.95
findTraceByIDFunction · 0.70
StartMethod · 0.65
StringMethod · 0.45
BytesReadMethod · 0.45

Tested by

no test coverage detected