@@ -10,6 +10,7 @@ import (
1010 "time"
1111
1212 "go.opentelemetry.io/collector/component"
13+ "go.opentelemetry.io/collector/exporter/exporterqueue"
1314 "go.opentelemetry.io/collector/exporter/internal"
1415)
1516
@@ -35,7 +36,7 @@ func (qb *DefaultBatcher) startReadingFlushingGoroutine() {
3536 defer qb .stopWG .Done ()
3637 for {
3738 // Read() blocks until the queue is non-empty or until the queue is stopped.
38- idx , ctx , req , ok := qb .queue .Read (context .Background ())
39+ ctx , req , done , ok := qb .queue .Read (context .Background ())
3940 if ! ok {
4041 qb .shutdownCh <- true
4142 return
@@ -54,7 +55,7 @@ func (qb *DefaultBatcher) startReadingFlushingGoroutine() {
5455 }
5556
5657 if mergeSplitErr != nil || reqList == nil {
57- qb . queue . OnProcessingFinished ( idx , mergeSplitErr )
58+ done ( mergeSplitErr )
5859 qb .currentBatchMu .Unlock ()
5960 continue
6061 }
@@ -64,42 +65,38 @@ func (qb *DefaultBatcher) startReadingFlushingGoroutine() {
6465 qb .currentBatch = nil
6566 qb .currentBatchMu .Unlock ()
6667 for i := 0 ; i < len (reqList ); i ++ {
67- qb .flush (batch {
68- req : reqList [i ],
69- ctx : ctx ,
70- idxList : []uint64 {idx },
71- })
68+ qb .flush (ctx , reqList [i ], []exporterqueue.DoneCallback {done })
7269 // TODO: handle partial failure
7370 }
7471 qb .resetTimer ()
7572 } else {
7673 qb .currentBatch = & batch {
77- req : reqList [0 ],
78- ctx : ctx ,
79- idxList : []uint64 { idx },
74+ req : reqList [0 ],
75+ ctx : ctx ,
76+ dones : []exporterqueue. DoneCallback { done },
8077 }
8178 qb .currentBatchMu .Unlock ()
8279 }
8380 } else {
8481 if qb .currentBatch == nil || qb .currentBatch .req == nil {
8582 qb .resetTimer ()
8683 qb .currentBatch = & batch {
87- req : req ,
88- ctx : ctx ,
89- idxList : []uint64 { idx },
84+ req : req ,
85+ ctx : ctx ,
86+ dones : []exporterqueue. DoneCallback { done },
9087 }
9188 } else {
9289 // TODO: consolidate implementation for the cases where MaxSizeConfig is specified and the case where it is not specified
9390 mergedReq , mergeErr := qb .currentBatch .req .MergeSplit (qb .currentBatch .ctx , qb .batchCfg .MaxSizeConfig , req )
9491 if mergeErr != nil {
95- qb . queue . OnProcessingFinished ( idx , mergeErr )
92+ done ( mergeErr )
9693 qb .currentBatchMu .Unlock ()
9794 continue
9895 }
9996 qb .currentBatch = & batch {
100- req : mergedReq [0 ],
101- ctx : qb .currentBatch .ctx ,
102- idxList : append (qb .currentBatch .idxList , idx ),
97+ req : mergedReq [0 ],
98+ ctx : qb .currentBatch .ctx ,
99+ dones : append (qb .currentBatch .dones , done ),
103100 }
104101 }
105102
@@ -109,7 +106,7 @@ func (qb *DefaultBatcher) startReadingFlushingGoroutine() {
109106 qb .currentBatchMu .Unlock ()
110107
111108 // flush() blocks until successfully started a goroutine for flushing.
112- qb .flush (batchToFlush )
109+ qb .flush (batchToFlush . ctx , batchToFlush . req , batchToFlush . dones )
113110 qb .resetTimer ()
114111 } else {
115112 qb .currentBatchMu .Unlock ()
@@ -168,7 +165,7 @@ func (qb *DefaultBatcher) flushCurrentBatchIfNecessary() {
168165 qb .currentBatchMu .Unlock ()
169166
170167 // flush() blocks until successfully started a goroutine for flushing.
171- qb .flush (batchToFlush )
168+ qb .flush (batchToFlush . ctx , batchToFlush . req , batchToFlush . dones )
172169 qb .resetTimer ()
173170}
174171
0 commit comments