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

Method checkBloom

tempodb/encoding/vparquet4/block_findtracebyid.go:36–63  ·  view source on GitHub ↗
(ctx context.Context, id common.ID)

Source from the content-addressed store, hash-verified

34)
35
36func (b *backendBlock) checkBloom(ctx context.Context, id common.ID) (found bool, err error) {
37 derivedCtx, span := tracer.Start(ctx, "parquet.backendBlock.checkBloom",
38 trace.WithAttributes(
39 attribute.String("blockID", b.meta.BlockID.String()),
40 attribute.String("tenantID", b.meta.TenantID),
41 ))
42 defer span.End()
43
44 shardKey := common.ShardKeyForTraceID(id, int(b.meta.BloomShardCount))
45 nameBloom := common.BloomName(shardKey)
46 span.SetAttributes(attribute.String("bloom", nameBloom))
47
48 bloomBytes, err := b.r.Read(derivedCtx, nameBloom, (uuid.UUID)(b.meta.BlockID), b.meta.TenantID, &backend.CacheInfo{
49 Meta: b.meta,
50 Role: cache.RoleBloom,
51 })
52 if err != nil {
53 return false, fmt.Errorf("error retrieving bloom %s (%s, %s): %w", nameBloom, b.meta.TenantID, b.meta.BlockID, err)
54 }
55
56 filter := &bloom.BloomFilter{}
57 _, err = filter.ReadFrom(bytes.NewReader(bloomBytes))
58 if err != nil {
59 return false, fmt.Errorf("error parsing bloom (%s, %s): %w", b.meta.TenantID, b.meta.BlockID, err)
60 }
61
62 return filter.Test(id), nil
63}
64
65func (b *backendBlock) checkIndex(ctx context.Context, id common.ID) (bool, int, error) {
66 if os.Getenv(EnvVarIndexName) != EnvVarIndexEnabledValue {

Callers 1

FindTraceByIDMethod · 0.95

Calls 6

ShardKeyForTraceIDFunction · 0.92
BloomNameFunction · 0.92
TestMethod · 0.80
StartMethod · 0.65
ReadMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected