-
Notifications
You must be signed in to change notification settings - Fork 524
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ingester/Generator Live trace cleanup (#4365)
* moved trace sizes somewhere shareable Signed-off-by: Joe Elliott <number101010@gmail.com> * use tracesizes in ingester Signed-off-by: Joe Elliott <number101010@gmail.com> * make tests work Signed-off-by: Joe Elliott <number101010@gmail.com> * trace bytes in generator Signed-off-by: Joe Elliott <number101010@gmail.com> * remove traceCount Signed-off-by: Joe Elliott <number101010@gmail.com> * live trace shenanigans Signed-off-by: Joe Elliott <number101010@gmail.com> * changelog Signed-off-by: Joe Elliott <number101010@gmail.com> * Update modules/generator/processor/localblocks/livetraces.go Co-authored-by: Mario <mariorvinas@gmail.com> * Update modules/ingester/instance.go Co-authored-by: Mario <mariorvinas@gmail.com> * Test cleanup. Add sz test, restore commented out and fix e2e Signed-off-by: Joe Elliott <number101010@gmail.com> * remove todo comment Signed-off-by: Joe Elliott <number101010@gmail.com> --------- Signed-off-by: Joe Elliott <number101010@gmail.com> Co-authored-by: Mario <mariorvinas@gmail.com>
- Loading branch information
1 parent
069bd1b
commit dc97da1
Showing
12 changed files
with
154 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
modules/generator/processor/localblocks/livetraces_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package localblocks | ||
|
||
import ( | ||
"math/rand/v2" | ||
"testing" | ||
"time" | ||
|
||
"github.com/grafana/tempo/pkg/util/test" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestLiveTracesSizesAndLen(t *testing.T) { | ||
lt := newLiveTraces() | ||
|
||
expectedSz := uint64(0) | ||
expectedLen := uint64(0) | ||
|
||
for i := 0; i < 100; i++ { | ||
id := test.ValidTraceID(nil) | ||
tr := test.MakeTrace(rand.IntN(5)+1, id) | ||
|
||
cutTime := time.Now() | ||
|
||
// add some traces and confirm size/len | ||
expectedLen++ | ||
for _, rs := range tr.ResourceSpans { | ||
expectedSz += uint64(rs.Size()) | ||
lt.Push(id, rs, 0) | ||
} | ||
|
||
require.Equal(t, expectedSz, lt.Size()) | ||
require.Equal(t, expectedLen, lt.Len()) | ||
|
||
// cut some traces and confirm size/len | ||
cutTraces := lt.CutIdle(cutTime, false) | ||
for _, tr := range cutTraces { | ||
for _, rs := range tr.Batches { | ||
expectedSz -= uint64(rs.Size()) | ||
} | ||
expectedLen-- | ||
} | ||
|
||
require.Equal(t, expectedSz, lt.Size()) | ||
require.Equal(t, expectedLen, lt.Len()) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.