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

Function TestRequestsByTraceID

modules/distributor/distributor_test.go:63–955  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

61}
62
63func TestRequestsByTraceID(t *testing.T) {
64 traceIDA := []byte{0x0A, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F}
65 traceIDB := []byte{0x0B, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F}
66 spanID := []byte{0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08}
67 // These 2 trace IDs are known to collide under fnv32
68 collision1, _ := util.HexStringToTraceID("fd5980503add11f09f80f77608c1b2da")
69 collision2, _ := util.HexStringToTraceID("091ea7803ade11f0998a055186ee1243")
70
71 tests := []struct {
72 name string
73 emptyTenant bool
74 batches []*v1.ResourceSpans
75 expectedKeys []uint32
76 expectedTraces []*tempopb.Trace
77 expectedIDs [][]byte
78 expectedErr error
79 expectedStarts []uint32
80 expectedEnds []uint32
81 }{
82 {
83 name: "empty",
84 batches: []*v1.ResourceSpans{
85 {},
86 {},
87 },
88 expectedKeys: []uint32{},
89 expectedTraces: []*tempopb.Trace{},
90 expectedIDs: [][]byte{},
91 expectedStarts: []uint32{},
92 expectedEnds: []uint32{},
93 },
94 {
95 name: "bad trace id",
96 batches: []*v1.ResourceSpans{
97 {
98 ScopeSpans: []*v1.ScopeSpans{
99 {
100 Spans: []*v1.Span{
101 {
102 TraceId: []byte{0x01},
103 },
104 },
105 },
106 },
107 },
108 },
109 expectedErr: status.Errorf(codes.InvalidArgument, "trace ids must be 128 bit, received 8 bits"),
110 },
111 {
112 name: "empty trace id",
113 batches: []*v1.ResourceSpans{
114 {
115 ScopeSpans: []*v1.ScopeSpans{
116 {
117 Spans: []*v1.Span{
118 {
119 TraceId: []byte{},
120 },

Callers

nothing calls this directly

Calls 5

HexStringToTraceIDFunction · 0.92
TokenForFunction · 0.92
requestsByTraceIDFunction · 0.85
RunMethod · 0.45
EqualMethod · 0.45

Tested by

no test coverage detected