fix(logs): Reject new logs if LoggerBatchProcessor is shutting down#5041
fix(logs): Reject new logs if LoggerBatchProcessor is shutting down#5041
LoggerBatchProcessor is shutting down#5041Conversation
Semver Impact of This PR🟢 Patch (bug fixes) 📋 Changelog PreviewThis is how your changes will appear in the changelog. New Features ✨
Bug Fixes 🐛Logs
Build / dependencies / internal 🔧Deps
Other
🤖 This preview updates automatically when you update the PR. |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.
| public void add(final @NotNull SentryLogEvent logEvent) { | ||
| if (isShuttingDown) { | ||
| return; | ||
| } |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
IMHO that's fine, at the point where the SDK is closed, it should also not send and discarded events.
Performance metrics 🚀
|
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| d217708 | 375.27 ms | 415.68 ms | 40.41 ms |
| d15471f | 310.66 ms | 368.19 ms | 57.53 ms |
| 27d7cf8 | 309.43 ms | 364.27 ms | 54.85 ms |
| d15471f | 361.89 ms | 378.07 ms | 16.18 ms |
| 27d7cf8 | 314.17 ms | 347.00 ms | 32.83 ms |
| cf708bd | 434.73 ms | 502.96 ms | 68.22 ms |
| 27d7cf8 | 306.76 ms | 366.66 ms | 59.90 ms |
| fc5ccaf | 322.49 ms | 405.25 ms | 82.76 ms |
| fcec2f2 | 311.35 ms | 384.94 ms | 73.59 ms |
| dba088c | 333.98 ms | 381.16 ms | 47.18 ms |
App size
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| d217708 | 1.58 MiB | 2.10 MiB | 532.97 KiB |
| d15471f | 1.58 MiB | 2.13 MiB | 559.54 KiB |
| 27d7cf8 | 1.58 MiB | 2.12 MiB | 549.42 KiB |
| d15471f | 1.58 MiB | 2.13 MiB | 559.54 KiB |
| 27d7cf8 | 1.58 MiB | 2.12 MiB | 549.42 KiB |
| cf708bd | 1.58 MiB | 2.11 MiB | 539.71 KiB |
| 27d7cf8 | 1.58 MiB | 2.12 MiB | 549.42 KiB |
| fc5ccaf | 1.58 MiB | 2.13 MiB | 557.54 KiB |
| fcec2f2 | 1.58 MiB | 2.12 MiB | 551.51 KiB |
| dba088c | 1.58 MiB | 2.13 MiB | 558.99 KiB |
LoggerBatchProcessor is shutting downLoggerBatchProcessor is shutting down
📜 Description
Reject new logs if
LoggerBatchProcessoris shutting down💡 Motivation and Context
💚 How did you test it?
📝 Checklist
sendDefaultPIIis enabled.🔮 Next steps