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

Function queryBlock

cmd/tempo-cli/cmd-query-blocks.go:141–178  ·  view source on GitHub ↗
(ctx context.Context, r backend.Reader, _ backend.Compactor, blockNum int, id uuid.UUID, tenantID string, traceID common.ID)

Source from the content-addressed store, hash-verified

139}
140
141func queryBlock(ctx context.Context, r backend.Reader, _ backend.Compactor, blockNum int, id uuid.UUID, tenantID string, traceID common.ID) (*queryResults, error) {
142 fmt.Print(".")
143 if blockNum%100 == 0 {
144 fmt.Print(strconv.Itoa(blockNum))
145 }
146
147 meta, err := r.BlockMeta(context.Background(), id, tenantID)
148 if err != nil && !errors.Is(err, backend.ErrDoesNotExist) {
149 return nil, err
150 }
151
152 if errors.Is(err, backend.ErrDoesNotExist) {
153 // tempo proper searches compacted blocks, b/c each querier has a different view of the backend blocks.
154 // however, with a single snaphot of the backend, we can only search the noncompacted blocks.
155 return nil, nil
156 }
157
158 block, err := encoding.OpenBlock(meta, r)
159 if err != nil {
160 return nil, err
161 }
162
163 searchOpts := common.SearchOptions{}
164 tempodb.SearchConfig{}.ApplyToOptions(&searchOpts)
165
166 res, err := block.FindTraceByID(ctx, traceID, searchOpts)
167 if err != nil {
168 return nil, err
169 }
170 if res == nil || res.Trace == nil {
171 return nil, nil
172 }
173
174 return &queryResults{
175 blockID: id,
176 trace: res.Trace,
177 }, nil
178}

Callers 2

queryBucketForSummaryFunction · 0.85
queryBucketFunction · 0.85

Calls 4

OpenBlockFunction · 0.92
ApplyToOptionsMethod · 0.80
BlockMetaMethod · 0.65
FindTraceByIDMethod · 0.65

Tested by

no test coverage detected