@@ -337,35 +337,42 @@ impl BatchLogProcessor {
337
337
match message_receiver. recv_timeout ( remaining_time) {
338
338
Ok ( BatchMessage :: ExportLog ( log) ) => {
339
339
logs. push ( log) ;
340
- if logs. len ( ) == config. max_export_batch_size
341
- || last_export_time. elapsed ( ) >= config. scheduled_delay
342
- {
340
+ if logs. len ( ) == config. max_export_batch_size {
341
+ otel_debug ! (
342
+ name: "BatchLogProcessor.ExportingDueToBatchSize" ,
343
+ ) ;
343
344
let _ = export_with_timeout_sync (
344
- remaining_time ,
345
+ config . max_export_timeout ,
345
346
& mut exporter,
346
347
logs. split_off ( 0 ) ,
347
348
& mut last_export_time,
348
349
) ;
349
350
}
350
351
}
351
352
Ok ( BatchMessage :: ForceFlush ( sender) ) => {
353
+ otel_debug ! ( name: "BatchLogProcessor.ExportingDueToForceFlush" ) ;
352
354
let result = export_with_timeout_sync (
353
- remaining_time ,
355
+ config . max_export_timeout ,
354
356
& mut exporter,
355
357
logs. split_off ( 0 ) ,
356
358
& mut last_export_time,
357
359
) ;
358
360
let _ = sender. send ( result) ;
359
361
}
360
362
Ok ( BatchMessage :: Shutdown ( sender) ) => {
363
+ otel_debug ! ( name: "BatchLogProcessor.ExportingDueToShutdown" ) ;
361
364
let result = export_with_timeout_sync (
362
- remaining_time ,
365
+ config . max_export_timeout ,
363
366
& mut exporter,
364
367
logs. split_off ( 0 ) ,
365
368
& mut last_export_time,
366
369
) ;
367
370
let _ = sender. send ( result) ;
368
371
372
+ otel_debug ! (
373
+ name: "BatchLogProcessor.ThreadExiting" ,
374
+ reason = "ShutdownRequested"
375
+ ) ;
369
376
//
370
377
// break out the loop and return from the current background thread.
371
378
//
@@ -375,19 +382,24 @@ impl BatchLogProcessor {
375
382
exporter. set_resource ( & resource) ;
376
383
}
377
384
Err ( RecvTimeoutError :: Timeout ) => {
385
+ otel_debug ! (
386
+ name: "BatchLogProcessor.ExportingDueToTimer" ,
387
+ ) ;
378
388
let _ = export_with_timeout_sync (
379
- remaining_time ,
389
+ config . max_export_timeout ,
380
390
& mut exporter,
381
391
logs. split_off ( 0 ) ,
382
392
& mut last_export_time,
383
393
) ;
384
394
}
385
- Err ( err) => {
386
- // TODO: this should not happen! Log the error and continue for now.
387
- otel_error ! (
388
- name: "BatchLogProcessor.InternalError" ,
389
- error = format!( "{}" , err)
395
+ Err ( RecvTimeoutError :: Disconnected ) => {
396
+ // Channel disconnected, only thing to do is break
397
+ // out (i.e exit the thread)
398
+ otel_debug ! (
399
+ name: "BatchLogProcessor.ThreadExiting" ,
400
+ reason = "MessageSenderDisconnected"
390
401
) ;
402
+ break ;
391
403
}
392
404
}
393
405
}
0 commit comments