Skip to content

Commit 9c210b0

Browse files
committed
Fix ordering issue
1 parent f040407 commit 9c210b0

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

opentelemetry-sdk/src/logs/log_processor.rs

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,18 @@ impl LogProcessor for BatchLogProcessor {
288288
.logs_sender
289289
.try_send(Box::new((record.clone(), instrumentation.clone())));
290290

291+
if result.is_err() {
292+
// Increment dropped logs count. The first time we have to drop a log,
293+
// emit a warning.
294+
if self.dropped_logs_count.fetch_add(1, Ordering::Relaxed) == 0 {
295+
otel_warn!(name: "BatchLogProcessor.LogDroppingStarted",
296+
message = "BatchLogProcessor dropped a LogRecord due to queue full/internal errors. No further log will be emitted for further drops until Shutdown. During Shutdown time, a log will be emitted with exact count of total logs dropped.");
297+
}
298+
return;
299+
}
300+
301+
// At this point, sending the log record to the data channel was successful.
302+
// Increment the current batch size and check if it has reached the max export batch size.
291303
if self.current_batch_size.fetch_add(1, Ordering::Relaxed) >= self.max_export_batch_size {
292304
// Check if the a control message for exporting logs is already sent to the worker thread.
293305
// If not, send a control message to export logs.
@@ -298,15 +310,6 @@ impl LogProcessor for BatchLogProcessor {
298310
)); // TODO: Handle error
299311
}
300312
}
301-
302-
if result.is_err() {
303-
// Increment dropped logs count. The first time we have to drop a log,
304-
// emit a warning.
305-
if self.dropped_logs_count.fetch_add(1, Ordering::Relaxed) == 0 {
306-
otel_warn!(name: "BatchLogProcessor.LogDroppingStarted",
307-
message = "BatchLogProcessor dropped a LogRecord due to queue full/internal errors. No further log will be emitted for further drops until Shutdown. During Shutdown time, a log will be emitted with exact count of total logs dropped.");
308-
}
309-
}
310313
}
311314

312315
fn force_flush(&self) -> LogResult<()> {

0 commit comments

Comments
 (0)