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

Function createTraceIterator

tempodb/encoding/vparquet4/block_traceql.go:2476–2586  ·  view source on GitHub ↗
(makeIter makeIterFn, resourceIter parquetquery.Iterator, conds []traceql.Condition, start, end uint64, allConditions bool, selectAll bool,
	sampler traceql.Sampler,
)

Source from the content-addressed store, hash-verified

2474}
2475
2476func createTraceIterator(makeIter makeIterFn, resourceIter parquetquery.Iterator, conds []traceql.Condition, start, end uint64, allConditions bool, selectAll bool,
2477 sampler traceql.Sampler,
2478) (parquetquery.Iterator, error) {
2479 iters := make([]parquetquery.Iterator, 0, 3)
2480 metaIters := make([]parquetquery.Iterator, 0)
2481
2482 if selectAll {
2483 for intrins, entry := range intrinsicColumnLookups {
2484 if entry.scope != intrinsicScopeTrace {
2485 continue
2486 }
2487 // These intrinsics aren't included in select all because they are not
2488 // useful for filtering or grouping.
2489 switch intrins {
2490 case traceql.IntrinsicTraceStartTime,
2491 traceql.IntrinsicServiceStats:
2492 continue
2493 }
2494 iters = append(iters, makeIter(entry.columnPath, nil, entry.columnPath))
2495 }
2496 } else {
2497 // add conditional iterators first. this way if someone searches for { traceDuration > 1s && span.foo = "bar"} the query will
2498 // be sped up by searching for traceDuration first. note that we can only set the predicates if all conditions is true.
2499 // otherwise we just pass the info up to the engine to make a choice
2500 for _, cond := range conds {
2501 switch cond.Attribute.Intrinsic {
2502 case traceql.IntrinsicTraceID:
2503 if cond.Op == traceql.OpNone && cond.CallBack != nil {
2504 metaIters = append(metaIters, makeIter(columnPathTraceID, parquetquery.NewCallbackPredicate(cond.CallBack), columnPathTraceID))
2505 } else {
2506 pred, err := createBytesPredicate(cond.Op, cond.Operands, false)
2507 if err != nil {
2508 return nil, err
2509 }
2510 iters = append(iters, makeIter(columnPathTraceID, pred, columnPathTraceID))
2511 }
2512 case traceql.IntrinsicTraceDuration:
2513 pred, err := createDurationPredicate(cond.Op, cond.Operands)
2514 if err != nil {
2515 return nil, err
2516 }
2517 iters = append(iters, makeIter(columnPathDurationNanos, pred, columnPathDurationNanos))
2518 case traceql.IntrinsicTraceStartTime:
2519 if start == 0 && end == 0 {
2520 iters = append(iters, makeIter(columnPathStartTimeUnixNano, nil, columnPathStartTimeUnixNano))
2521 }
2522 case traceql.IntrinsicTraceRootSpan:
2523 pred, err := createStringPredicate(cond.Op, cond.Operands)
2524 if err != nil {
2525 return nil, err
2526 }
2527 iters = append(iters, makeIter(columnPathRootSpanName, pred, columnPathRootSpanName))
2528 case traceql.IntrinsicTraceRootService:
2529 pred, err := createStringPredicate(cond.Op, cond.Operands)
2530 if err != nil {
2531 return nil, err
2532 }
2533 iters = append(iters, makeIter(columnPathRootServiceName, pred, columnPathRootServiceName))

Callers 1

createAllIteratorFunction · 0.70

Calls 10

NewCallbackPredicateFunction · 0.92
NewIntBetweenPredicateFunction · 0.92
NewLeftJoinIteratorFunction · 0.92
WithPoolFunction · 0.92
createBytesPredicateFunction · 0.70
createDurationPredicateFunction · 0.70
createStringPredicateFunction · 0.70
newSamplingPredicateFunction · 0.70
newTraceCollectorFunction · 0.70

Tested by

no test coverage detected