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

Function TestMaxTraceSizeExceededWithAccumulation

pkg/livetraces/livetraces_test.go:120–151  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

118}
119
120func TestMaxTraceSizeExceededWithAccumulation(t *testing.T) {
121 var buf bytes.Buffer
122 logger := kitlog.NewJSONLogger(kitlog.NewSyncWriter(&buf))
123
124 originalLogger := log.Logger
125 log.Logger = logger
126 defer func() { log.Logger = originalLogger }()
127
128 const (
129 batchSize = uint64(300)
130 maxTraceSize = uint64(500)
131 )
132
133 lt := New(func(_ *v1.ResourceSpans) uint64 { return batchSize }, time.Hour, time.Hour, testTenantID)
134
135 id := test.ValidTraceID(nil)
136 tr := test.MakeTrace(1, id)
137
138 // First push should succeed
139 lt.Push(id, tr.ResourceSpans[0], 0)
140
141 // Second push should fail: batchSize + batchSize > maxTraceSize
142 err := lt.PushWithTimestampAndLimits(time.Now(), id, tr.ResourceSpans[0], 0, maxTraceSize)
143
144 require.Equal(t, ErrMaxTraceSizeExceeded, err)
145
146 logOutput := buf.String()
147 require.Contains(t, logOutput, "max trace size exceeded")
148 require.Contains(t, logOutput, fmt.Sprintf(`"max":%d`, maxTraceSize))
149 require.Contains(t, logOutput, fmt.Sprintf(`"reqSize":%d`, batchSize))
150 require.Contains(t, logOutput, fmt.Sprintf(`"totalSize":%d`, batchSize))
151}
152
153func BenchmarkLiveTracesWrite(b *testing.B) {
154 lt := New(func(rs *v1.ResourceSpans) uint64 { return uint64(rs.Size()) }, 0, 0, testTenantID)

Callers

nothing calls this directly

Calls 8

ValidTraceIDFunction · 0.92
MakeTraceFunction · 0.92
NewFunction · 0.70
NowMethod · 0.65
PushMethod · 0.45
EqualMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected