Skip to content

Commit

Permalink
[chore] Remove unnecessary context from Batch.split
Browse files Browse the repository at this point in the history
Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
  • Loading branch information
bogdandrutu committed Oct 21, 2024
1 parent 8f20a07 commit bd2980b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
12 changes: 6 additions & 6 deletions processor/batchprocessor/batch_processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ type batch[T any] interface {
// export the current batch
export(ctx context.Context, req T) error

// splitBatch returns a full request built from pending items.
splitBatch(ctx context.Context, sendBatchMaxSize int) (sentBatchSize int, req T)
// split returns a full request built from pending items.
split(sendBatchMaxSize int) (sentBatchSize int, req T)

// itemCount returns the size of the current batch
itemCount() int
Expand Down Expand Up @@ -255,7 +255,7 @@ func (b *shard[T]) resetTimer() {
}

func (b *shard[T]) sendItems(trigger trigger) {
sent, req := b.batch.splitBatch(b.exportCtx, b.processor.sendBatchMaxSize)
sent, req := b.batch.split(b.processor.sendBatchMaxSize)

err := b.batch.export(b.exportCtx, req)
if err != nil {
Expand Down Expand Up @@ -447,7 +447,7 @@ func (bt *batchTraces) export(ctx context.Context, td ptrace.Traces) error {
return bt.nextConsumer.ConsumeTraces(ctx, td)
}

func (bt *batchTraces) splitBatch(_ context.Context, sendBatchMaxSize int) (int, ptrace.Traces) {
func (bt *batchTraces) split(sendBatchMaxSize int) (int, ptrace.Traces) {
var td ptrace.Traces
var sent int
if sendBatchMaxSize > 0 && bt.itemCount() > sendBatchMaxSize {
Expand Down Expand Up @@ -486,7 +486,7 @@ func (bm *batchMetrics) export(ctx context.Context, md pmetric.Metrics) error {
return bm.nextConsumer.ConsumeMetrics(ctx, md)
}

func (bm *batchMetrics) splitBatch(_ context.Context, sendBatchMaxSize int) (int, pmetric.Metrics) {
func (bm *batchMetrics) split(sendBatchMaxSize int) (int, pmetric.Metrics) {
var md pmetric.Metrics
var sent int
if sendBatchMaxSize > 0 && bm.dataPointCount > sendBatchMaxSize {
Expand Down Expand Up @@ -535,7 +535,7 @@ func (bl *batchLogs) export(ctx context.Context, ld plog.Logs) error {
return bl.nextConsumer.ConsumeLogs(ctx, ld)
}

func (bl *batchLogs) splitBatch(_ context.Context, sendBatchMaxSize int) (int, plog.Logs) {
func (bl *batchLogs) split(sendBatchMaxSize int) (int, plog.Logs) {
var ld plog.Logs
var sent int

Expand Down
2 changes: 1 addition & 1 deletion processor/batchprocessor/batch_processor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -691,7 +691,7 @@ func TestBatchMetrics_UnevenBatchMaxSize(t *testing.T) {

batchMetrics.add(md)
require.Equal(t, dataPointsPerMetric*metricsCount, batchMetrics.dataPointCount)
sent, req := batchMetrics.splitBatch(ctx, sendBatchMaxSize)
sent, req := batchMetrics.split(sendBatchMaxSize)
sendErr := batchMetrics.export(ctx, req)
require.NoError(t, sendErr)
require.Equal(t, sendBatchMaxSize, sent)
Expand Down

0 comments on commit bd2980b

Please sign in to comment.