Skip to content

Commit

Permalink
avoid ch creation
Browse files Browse the repository at this point in the history
  • Loading branch information
jmacd committed May 31, 2024
1 parent ac48602 commit 2634c49
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions collector/processor/concurrentbatchprocessor/batch_processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -441,26 +441,28 @@ func (bp *batchProcessor) countRelease(bytes int64) {
}

func (b *shard) consumeAndWait(ctx context.Context, data any) error {
respCh := make(chan error, 1)
item := dataItem{
parentCtx: ctx,
data: data,
responseCh: respCh,
}

var itemCount int
switch telem := data.(type) {
case ptrace.Traces:
item.count = telem.SpanCount()
itemCount = telem.SpanCount()
case pmetric.Metrics:
item.count = telem.DataPointCount()
itemCount = telem.DataPointCount()
case plog.Logs:
item.count = telem.LogRecordCount()
itemCount = telem.LogRecordCount()
}

if item.count == 0 {
if itemCount == 0 {
return nil
}

respCh := make(chan error, 1)
item := dataItem{
parentCtx: ctx,
data: data,
responseCh: respCh,
count: itemCount,
}
bytes := int64(b.batch.sizeBytes(data))

if bytes > b.processor.limitBytes {
Expand Down

0 comments on commit 2634c49

Please sign in to comment.