Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@

- Only attach user attributes to logs if `sendDefaultPii` is enabled ([#5036](https://github.com/getsentry/sentry-java/pull/5036))

### Fixes

- Reject new logs if `LoggerBatchProcessor` is shutting down ([#5041](https://github.com/getsentry/sentry-java/pull/5041))

### Dependencies

- Bump Native SDK from v0.12.2 to v0.12.3 ([#5012](https://github.com/getsentry/sentry-java/pull/5012))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public class LoggerBatchProcessor implements ILoggerBatchProcessor {
private volatile @Nullable Future<?> scheduledFlush;
private final @NotNull AutoClosableReentrantLock scheduleLock = new AutoClosableReentrantLock();
private volatile boolean hasScheduled = false;
private volatile boolean isShuttingDown = false;

private final @NotNull ReusableCountLatch pendingCount = new ReusableCountLatch();

Expand All @@ -51,6 +52,9 @@ public LoggerBatchProcessor(

@Override
public void add(final @NotNull SentryLogEvent logEvent) {
if (isShuttingDown) {
return;
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Logs dropped during shutdown not recorded as lost events

Low Severity

When isShuttingDown is true, the add method silently returns without recording the dropped log event via recordLostEvent(). This is inconsistent with the queue overflow handling just below, which properly records both LogItem and LogByte lost events with DiscardReason.QUEUE_OVERFLOW. This inconsistency means logs discarded during shutdown won't appear in client reports, reducing observability into event loss.

Fix in Cursor Fix in Web

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMHO that's fine, at the point where the SDK is closed, it should also not send and discarded events.

if (pendingCount.getCount() >= MAX_QUEUE_SIZE) {
options
.getClientReportRecorder()
Expand All @@ -70,6 +74,7 @@ public void add(final @NotNull SentryLogEvent logEvent) {
@SuppressWarnings("FutureReturnValueIgnored")
@Override
public void close(final boolean isRestarting) {
isShuttingDown = true;
if (isRestarting) {
maybeSchedule(true, true);
executorService.submit(() -> executorService.close(options.getShutdownTimeoutMillis()));
Expand Down
Loading