nolint: revive,unparam
(t *testing.T, ctx context.Context, client *kgo.Client, dur, interval time.Duration, encode encodingFn)
| 68 | |
| 69 | // nolint: revive,unparam |
| 70 | func SendTracesFor(t *testing.T, ctx context.Context, client *kgo.Client, dur, interval time.Duration, encode encodingFn) []*kgo.Record { |
| 71 | ticker := time.NewTicker(interval) |
| 72 | defer ticker.Stop() |
| 73 | |
| 74 | timer := time.NewTimer(dur) |
| 75 | defer timer.Stop() |
| 76 | |
| 77 | producedRecords := make([]*kgo.Record, 0) |
| 78 | |
| 79 | for { |
| 80 | select { |
| 81 | case <-ctx.Done(): // Exit the function if the context is done |
| 82 | return producedRecords |
| 83 | case <-timer.C: // Exit the function when the timer is done |
| 84 | return producedRecords |
| 85 | case <-ticker.C: |
| 86 | records := SendReq(ctx, t, client, encode, util.FakeTenantID) |
| 87 | producedRecords = append(producedRecords, records...) |
| 88 | } |
| 89 | } |
| 90 | } |
| 91 | |
| 92 | func generateTraceID(t testing.TB) []byte { |
| 93 | traceID := make([]byte, 16) |