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)
| 3448 | // containing all the matching spans. These spans already contain all span-level and |
| 3449 | // resource-level data. |
| 3450 | func (c *traceCollector) KeepGroup(res *parquetquery.IteratorResult) bool { |
| 3451 | finalSpanset := getSpanset() |
| 3452 | c.traceAttrs = c.traceAttrs[:0] |
| 3453 | |
| 3454 | for _, e := range res.Entries { |
| 3455 | switch e.Key { |
| 3456 | case columnPathTraceID: |
| 3457 | finalSpanset.TraceID = e.Value.ByteArray() |
| 3458 | c.traceAttrs = append(c.traceAttrs, attrVal{traceql.IntrinsicTraceIDAttribute, traceql.NewStaticString(util.TraceIDToHexString(e.Value.ByteArray()))}) |
| 3459 | case columnPathStartTimeUnixNano: |
| 3460 | finalSpanset.StartTimeUnixNanos = e.Value.Uint64() |
| 3461 | case columnPathDurationNanos: |
| 3462 | finalSpanset.DurationNanos = e.Value.Uint64() |
| 3463 | c.traceAttrs = append(c.traceAttrs, attrVal{traceql.IntrinsicTraceDurationAttribute, traceql.NewStaticDuration(time.Duration(finalSpanset.DurationNanos))}) |
| 3464 | case columnPathRootSpanName: |
| 3465 | finalSpanset.RootSpanName = unsafeToString(e.Value.Bytes()) |
| 3466 | c.traceAttrs = append(c.traceAttrs, attrVal{traceql.IntrinsicTraceRootSpanAttribute, traceql.NewStaticString(finalSpanset.RootSpanName)}) |
| 3467 | case columnPathRootServiceName: |
| 3468 | finalSpanset.RootServiceName = unsafeToString(e.Value.Bytes()) |
| 3469 | c.traceAttrs = append(c.traceAttrs, attrVal{traceql.IntrinsicTraceRootServiceAttribute, traceql.NewStaticString(finalSpanset.RootServiceName)}) |
| 3470 | } |
| 3471 | } |
| 3472 | |
| 3473 | // Pre-allocate the final number of spans and serviceStats |
| 3474 | numSpans := 0 |
| 3475 | numServiceStats := 0 |
| 3476 | for _, e := range res.OtherEntries { |
| 3477 | if _, ok := e.Value.(*span); ok { |
| 3478 | numSpans++ |
| 3479 | } else if _, ok := e.Value.(traceql.ServiceStats); ok { |
| 3480 | numServiceStats++ |
| 3481 | } |
| 3482 | } |
| 3483 | if cap(finalSpanset.Spans) < numSpans { |
| 3484 | finalSpanset.Spans = make([]traceql.Span, 0, numSpans) |
| 3485 | } |
| 3486 | for _, e := range res.OtherEntries { |
| 3487 | if span, ok := e.Value.(*span); ok { |
| 3488 | finalSpanset.Spans = append(finalSpanset.Spans, span) |
| 3489 | } |
| 3490 | } |
| 3491 | |
| 3492 | // loop over all spans and add the trace-level attributes |
| 3493 | if len(c.traceAttrs) > 0 { |
| 3494 | for _, s := range finalSpanset.Spans { |
| 3495 | s := s.(*span) |
| 3496 | s.setTraceAttrs(c.traceAttrs) |
| 3497 | } |
| 3498 | } |
| 3499 | |
| 3500 | if numServiceStats > 0 { |
| 3501 | finalSpanset.ServiceStats = make(map[string]traceql.ServiceStats, numServiceStats) |
| 3502 | for _, e := range res.OtherEntries { |
| 3503 | if serviceStats, ok := e.Value.(traceql.ServiceStats); ok { |
| 3504 | finalSpanset.ServiceStats[e.Key] = serviceStats |
| 3505 | } |
| 3506 | } |
| 3507 | } |
nothing calls this directly
no test coverage detected