KeepGroup is called once per trace and creates its final spanset containing all the matching spans. These spans already contain all span-level and resource-level data.
(res *parquetquery.IteratorResult)
| 3539 | // containing all the matching spans. These spans already contain all span-level and |
| 3540 | // resource-level data. |
| 3541 | func (c *traceCollector) KeepGroup(res *parquetquery.IteratorResult) bool { |
| 3542 | finalSpanset := getSpanset() |
| 3543 | c.traceAttrs = c.traceAttrs[:0] |
| 3544 | |
| 3545 | for _, e := range res.Entries { |
| 3546 | switch e.Key { |
| 3547 | case columnPathTraceID: |
| 3548 | finalSpanset.TraceID = e.Value.ByteArray() |
| 3549 | c.traceAttrs = append(c.traceAttrs, attrVal{traceql.IntrinsicTraceIDAttribute, traceql.NewStaticString(util.TraceIDToHexString(e.Value.ByteArray()))}) |
| 3550 | case columnPathStartTimeUnixNano: |
| 3551 | finalSpanset.StartTimeUnixNanos = e.Value.Uint64() |
| 3552 | case columnPathDurationNanos: |
| 3553 | finalSpanset.DurationNanos = e.Value.Uint64() |
| 3554 | c.traceAttrs = append(c.traceAttrs, attrVal{traceql.IntrinsicTraceDurationAttribute, traceql.NewStaticDuration(time.Duration(finalSpanset.DurationNanos))}) |
| 3555 | case columnPathRootSpanName: |
| 3556 | finalSpanset.RootSpanName = unsafeToString(e.Value.Bytes()) |
| 3557 | c.traceAttrs = append(c.traceAttrs, attrVal{traceql.IntrinsicTraceRootSpanAttribute, traceql.NewStaticString(finalSpanset.RootSpanName)}) |
| 3558 | case columnPathRootServiceName: |
| 3559 | finalSpanset.RootServiceName = unsafeToString(e.Value.Bytes()) |
| 3560 | c.traceAttrs = append(c.traceAttrs, attrVal{traceql.IntrinsicTraceRootServiceAttribute, traceql.NewStaticString(finalSpanset.RootServiceName)}) |
| 3561 | } |
| 3562 | } |
| 3563 | |
| 3564 | // Pre-allocate the final number of spans and serviceStats |
| 3565 | numSpans := 0 |
| 3566 | numServiceStats := 0 |
| 3567 | for _, e := range res.OtherEntries { |
| 3568 | if _, ok := e.Value.(*span); ok { |
| 3569 | numSpans++ |
| 3570 | } else if _, ok := e.Value.(traceql.ServiceStats); ok { |
| 3571 | numServiceStats++ |
| 3572 | } |
| 3573 | } |
| 3574 | if cap(finalSpanset.Spans) < numSpans { |
| 3575 | finalSpanset.Spans = make([]traceql.Span, 0, numSpans) |
| 3576 | } |
| 3577 | for _, e := range res.OtherEntries { |
| 3578 | if span, ok := e.Value.(*span); ok { |
| 3579 | finalSpanset.Spans = append(finalSpanset.Spans, span) |
| 3580 | } |
| 3581 | } |
| 3582 | |
| 3583 | // loop over all spans and add the trace-level attributes |
| 3584 | if len(c.traceAttrs) > 0 { |
| 3585 | for _, s := range finalSpanset.Spans { |
| 3586 | s := s.(*span) |
| 3587 | s.setTraceAttrs(c.traceAttrs) |
| 3588 | } |
| 3589 | } |
| 3590 | |
| 3591 | if numServiceStats > 0 { |
| 3592 | finalSpanset.ServiceStats = make(map[string]traceql.ServiceStats, numServiceStats) |
| 3593 | for _, e := range res.OtherEntries { |
| 3594 | if serviceStats, ok := e.Value.(traceql.ServiceStats); ok { |
| 3595 | finalSpanset.ServiceStats[e.Key] = serviceStats |
| 3596 | } |
| 3597 | } |
| 3598 | } |
nothing calls this directly
no test coverage detected