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

Function createTraceIterator

tempodb/encoding/vparquet5/block_traceql.go:2557–2667  ·  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

2555}
2556
2557func createTraceIterator(makeIter makeIterFn, resourceIter parquetquery.Iterator, conds []traceql.Condition, start, end uint64, allConditions bool, selectAll bool,
2558 sampler traceql.Sampler,
2559) (parquetquery.Iterator, error) {
2560 iters := make([]parquetquery.Iterator, 0, 3)
2561 metaIters := make([]parquetquery.Iterator, 0)
2562
2563 if selectAll {
2564 for intrins, entry := range intrinsicColumnLookups {
2565 if entry.scope != intrinsicScopeTrace {
2566 continue
2567 }
2568 // These intrinsics aren't included in select all because they are not
2569 // useful for filtering or grouping.
2570 switch intrins {
2571 case traceql.IntrinsicTraceStartTime,
2572 traceql.IntrinsicServiceStats:
2573 continue
2574 }
2575 iters = append(iters, makeIter(entry.columnPath, nil, entry.columnPath))
2576 }
2577 } else {
2578 // add conditional iterators first. this way if someone searches for { traceDuration > 1s && span.foo = "bar"} the query will
2579 // be sped up by searching for traceDuration first. note that we can only set the predicates if all conditions is true.
2580 // otherwise we just pass the info up to the engine to make a choice
2581 for _, cond := range conds {
2582 switch cond.Attribute.Intrinsic {
2583 case traceql.IntrinsicTraceID:
2584 if cond.Op == traceql.OpNone && cond.CallBack != nil {
2585 metaIters = append(metaIters, makeIter(columnPathTraceID, parquetquery.NewCallbackPredicate(cond.CallBack), columnPathTraceID))
2586 } else {
2587 pred, err := createBytesPredicate(cond.Op, cond.Operands, false)
2588 if err != nil {
2589 return nil, err
2590 }
2591 iters = append(iters, makeIter(columnPathTraceID, pred, columnPathTraceID))
2592 }
2593 case traceql.IntrinsicTraceDuration:
2594 pred, err := createDurationPredicate(cond.Op, cond.Operands)
2595 if err != nil {
2596 return nil, err
2597 }
2598 iters = append(iters, makeIter(columnPathDurationNanos, pred, columnPathDurationNanos))
2599 case traceql.IntrinsicTraceStartTime:
2600 if start == 0 && end == 0 {
2601 iters = append(iters, makeIter(columnPathStartTimeUnixNano, nil, columnPathStartTimeUnixNano))
2602 }
2603 case traceql.IntrinsicTraceRootSpan:
2604 pred, err := createStringPredicate(cond.Op, cond.Operands)
2605 if err != nil {
2606 return nil, err
2607 }
2608 iters = append(iters, makeIter(columnPathRootSpanName, pred, columnPathRootSpanName))
2609 case traceql.IntrinsicTraceRootService:
2610 pred, err := createStringPredicate(cond.Op, cond.Operands)
2611 if err != nil {
2612 return nil, err
2613 }
2614 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