SortTrace deeply sorts a *tempopb.Trace. All scopes, spans, events, etc are sorted by data intrinsic like timestamp or id.
(t *tempopb.Trace)
| 11 | // SortTrace deeply sorts a *tempopb.Trace. All scopes, spans, events, etc are sorted by |
| 12 | // data intrinsic like timestamp or id. |
| 13 | func SortTrace(t *tempopb.Trace) { |
| 14 | // Sort bottom up by span start times |
| 15 | for _, b := range t.ResourceSpans { |
| 16 | for _, ss := range b.ScopeSpans { |
| 17 | for _, span := range ss.Spans { |
| 18 | sort.Slice(span.Events, func(i, j int) bool { |
| 19 | return compareEvents(span.Events[i], span.Events[j]) |
| 20 | }) |
| 21 | sort.Slice(span.Links, func(i, j int) bool { |
| 22 | return compareLinks(span.Links[i], span.Links[j]) |
| 23 | }) |
| 24 | } |
| 25 | sort.Slice(ss.Spans, func(i, j int) bool { |
| 26 | return compareSpans(ss.Spans[i], ss.Spans[j]) |
| 27 | }) |
| 28 | } |
| 29 | sort.Slice(b.ScopeSpans, func(i, j int) bool { |
| 30 | return compareScopeSpans(b.ScopeSpans[i], b.ScopeSpans[j]) |
| 31 | }) |
| 32 | } |
| 33 | sort.Slice(t.ResourceSpans, func(i, j int) bool { |
| 34 | return compareBatches(t.ResourceSpans[i], t.ResourceSpans[j]) |
| 35 | }) |
| 36 | } |
| 37 | |
| 38 | // SortTraceAndAttributes sorts a *tempopb.Trace like SortTrace, but also |
| 39 | // sorts all resource and span attributes by name. |