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

Function createTestBlock

tempodb/encoding/vparquet4/compactor_test.go:113–144  ·  view source on GitHub ↗

createTestBlock with the number of given traces and the needed sizes. Trace IDs are guaranteed to be monotonically increasing so that the block will be iterated in order. nolint: revive

(t testing.TB, ctx context.Context, cfg *common.BlockConfig, r backend.Reader, w backend.Writer, traceCount, batchCount, spanCount, replicationFactor int, dc backend.DedicatedColumns)

Source from the content-addressed store, hash-verified

111// the block will be iterated in order.
112// nolint: revive
113func createTestBlock(t testing.TB, ctx context.Context, cfg *common.BlockConfig, r backend.Reader, w backend.Writer, traceCount, batchCount, spanCount, replicationFactor int, dc backend.DedicatedColumns) *backend.BlockMeta {
114 inMeta := &backend.BlockMeta{
115 TenantID: tenantID,
116 BlockID: backend.NewUUID(),
117 TotalObjects: int64(traceCount),
118 ReplicationFactor: uint32(replicationFactor),
119 DedicatedColumns: dc,
120 }
121
122 sb, outMeta := newStreamingBlock(ctx, cfg, inMeta, r, w, tempo_io.NewBufferedWriter)
123
124 for i := 0; i < traceCount; i++ {
125 id := make([]byte, 16)
126 _, err := crand.Read(id)
127 require.NoError(t, err)
128
129 tr := test.AddDedicatedAttributes(test.MakeTraceWithSpanCount(batchCount, spanCount, id))
130 trp, connected := traceToParquet(inMeta, id, tr, nil)
131 require.False(t, connected)
132
133 require.NoError(t, sb.Add(trp, 0, 0))
134 if sb.EstimatedBufferedBytes() > 20_000_000 {
135 _, err := sb.Flush()
136 require.NoError(t, err)
137 }
138 }
139
140 _, err := sb.Complete()
141 require.NoError(t, err)
142
143 return outMeta
144}
145
146func TestValueAlloc(_ *testing.T) {
147 _ = make([]parquet.Value, 1_000_000)

Callers 3

benchmarkCompactorFunction · 0.70
BenchmarkCompactorDupesFunction · 0.70
TestCompactFunction · 0.70

Calls 10

NewUUIDFunction · 0.92
AddDedicatedAttributesFunction · 0.92
MakeTraceWithSpanCountFunction · 0.92
newStreamingBlockFunction · 0.70
traceToParquetFunction · 0.70
ReadMethod · 0.65
AddMethod · 0.65
FlushMethod · 0.65
CompleteMethod · 0.45

Tested by

no test coverage detected