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

Function SortTrace

pkg/model/trace/sort.go:13–36  ·  view source on GitHub ↗

SortTrace deeply sorts a *tempopb.Trace. All scopes, spans, events, etc are sorted by data intrinsic like timestamp or id.

(t *tempopb.Trace)

Source from the content-addressed store, hash-verified

11// SortTrace deeply sorts a *tempopb.Trace. All scopes, spans, events, etc are sorted by
12// data intrinsic like timestamp or id.
13func 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.

Callers 15

testCompactionRoundtripFunction · 0.92
runWALTestWithAppendModeFunction · 0.92
TestPartialReplayFunction · 0.92
TestWalBlockMetaSnapshotFunction · 0.92
TestWalBlockTombstoneFunction · 0.92
testWalBlockFunction · 0.92
TestPartialReplayFunction · 0.92
TestWalBlockMetaSnapshotFunction · 0.92
TestWalBlockTombstoneFunction · 0.92

Calls 5

compareEventsFunction · 0.85
compareLinksFunction · 0.85
compareSpansFunction · 0.70
compareScopeSpansFunction · 0.70
compareBatchesFunction · 0.70

Tested by 15

testCompactionRoundtripFunction · 0.74
runWALTestWithAppendModeFunction · 0.74
TestPartialReplayFunction · 0.74
TestWalBlockMetaSnapshotFunction · 0.74
TestWalBlockTombstoneFunction · 0.74
testWalBlockFunction · 0.74
TestPartialReplayFunction · 0.74
TestWalBlockMetaSnapshotFunction · 0.74
TestWalBlockTombstoneFunction · 0.74