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

Function SortTraceAndAttributes

pkg/model/trace/sort.go:40–71  ·  view source on GitHub ↗

SortTraceAndAttributes sorts a *tempopb.Trace like SortTrace, but also sorts all resource and span attributes by name.

(t *tempopb.Trace)

Source from the content-addressed store, hash-verified

38// SortTraceAndAttributes sorts a *tempopb.Trace like SortTrace, but also
39// sorts all resource and span attributes by name.
40func SortTraceAndAttributes(t *tempopb.Trace) {
41 SortTrace(t)
42 for _, b := range t.ResourceSpans {
43 if res := b.Resource; res != nil {
44 sort.Slice(res.Attributes, func(i, j int) bool {
45 return res.Attributes[i].Key < res.Attributes[j].Key
46 })
47 }
48 for _, ss := range b.ScopeSpans {
49 if ss.Scope != nil {
50 sort.Slice(ss.Scope.Attributes, func(i, j int) bool {
51 return ss.Scope.Attributes[i].Key < ss.Scope.Attributes[j].Key
52 })
53 }
54 for _, span := range ss.Spans {
55 sort.Slice(span.Attributes, func(i, j int) bool {
56 return span.Attributes[i].Key < span.Attributes[j].Key
57 })
58 for _, event := range span.Events {
59 sort.Slice(event.Attributes, func(i, j int) bool {
60 return event.Attributes[i].Key < event.Attributes[j].Key
61 })
62 }
63 for _, link := range span.Links {
64 sort.Slice(link.Attributes, func(i, j int) bool {
65 return link.Attributes[i].Key < link.Attributes[j].Key
66 })
67 }
68 }
69 }
70 }
71}
72
73func compareBatches(a, b *v1.ResourceSpans) bool {
74 if len(a.ScopeSpans) > 0 && len(b.ScopeSpans) > 0 {

Callers 6

testCompleteBlockFunction · 0.92
AssertEqualTraceFunction · 0.92
equalTracesFunction · 0.92
TestSortTraceFunction · 0.85

Calls 1

SortTraceFunction · 0.70

Tested by 4

testCompleteBlockFunction · 0.74
TestSortTraceFunction · 0.68