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

Method checkIndex

tempodb/encoding/vparquet3/block_findtracebyid.go:65–101  ·  view source on GitHub ↗
(ctx context.Context, id common.ID)

Source from the content-addressed store, hash-verified

63}
64
65func (b *backendBlock) checkIndex(ctx context.Context, id common.ID) (bool, int, error) {
66 if os.Getenv(EnvVarIndexName) != EnvVarIndexEnabledValue {
67 // Index lookup disabled
68 return true, -1, nil
69 }
70
71 derivedCtx, span := tracer.Start(ctx, "parquet3.backendBlock.checkIndex",
72 trace.WithAttributes(
73 attribute.String("blockID", b.meta.BlockID.String()),
74 attribute.String("tenantID", b.meta.TenantID),
75 ))
76 defer span.End()
77
78 indexBytes, err := b.r.Read(derivedCtx, common.NameIndex, (uuid.UUID)(b.meta.BlockID), b.meta.TenantID, &backend.CacheInfo{
79 Meta: b.meta,
80 Role: cache.RoleTraceIDIdx,
81 })
82 if errors.Is(err, backend.ErrDoesNotExist) {
83 return true, -1, nil
84 }
85 if err != nil {
86 return false, -1, fmt.Errorf("error retrieving index (%s, %s): %w", b.meta.TenantID, b.meta.BlockID, err)
87 }
88
89 index, err := unmarshalIndex(indexBytes)
90 if err != nil {
91 return false, -1, fmt.Errorf("error parsing index (%s, %s): %w", b.meta.TenantID, b.meta.BlockID, err)
92 }
93
94 rowGroup := index.Find(id)
95 if rowGroup == -1 {
96 // Ruled out by index
97 return false, -1, nil
98 }
99
100 return true, rowGroup, nil
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",

Callers 1

FindTraceByIDMethod · 0.95

Calls 5

unmarshalIndexFunction · 0.70
StartMethod · 0.65
ReadMethod · 0.65
FindMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected