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

Method swapParentIDs

modules/frontend/combiner/trace_by_id_deduper.go:98–116  ·  view source on GitHub ↗

swapParentIDs corrects ParentSpanID of all spans that are children of the server spans whose IDs we deduped.

(oldToNewSpanIDs map[uint64]uint64)

Source from the content-addressed store, hash-verified

96// swapParentIDs corrects ParentSpanID of all spans that are children of the server
97// spans whose IDs we deduped.
98func (s *spanIDDeduper) swapParentIDs(oldToNewSpanIDs map[uint64]uint64) {
99 if len(oldToNewSpanIDs) == 0 {
100 return
101 }
102 for _, batch := range s.trace.ResourceSpans {
103 for _, ils := range batch.ScopeSpans {
104 for _, span := range ils.Spans {
105 if len(span.GetParentSpanId()) > 0 {
106 parentSpanID := binary.BigEndian.Uint64(span.GetParentSpanId())
107 if newParentID, ok := oldToNewSpanIDs[parentSpanID]; ok {
108 if binary.BigEndian.Uint64(span.SpanId) != newParentID {
109 binary.BigEndian.PutUint64(span.ParentSpanId, newParentID)
110 }
111 }
112 }
113 }
114 }
115 }
116}
117
118// makeUniqueSpanID returns a new ID that is not used in the trace,
119// or an error if such ID cannot be generated, which is unlikely,

Callers 1

dedupeSpanIDsMethod · 0.95

Calls 1

GetParentSpanIdMethod · 0.80

Tested by

no test coverage detected