swapParentIDs corrects ParentSpanID of all spans that are children of the server spans whose IDs we deduped.
(oldToNewSpanIDs map[uint64]uint64)
| 96 | // swapParentIDs corrects ParentSpanID of all spans that are children of the server |
| 97 | // spans whose IDs we deduped. |
| 98 | func (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, |
no test coverage detected