feat: Add async event processing#5558
Draft
adinauer wants to merge 3 commits into
Draft
Conversation
Document the proposed opt-in async processing pipeline for EventProcessor callbacks, including queue behavior, flush semantics, and testing coverage. Co-Authored-By: Claude <noreply@anthropic.com>
Add EventProcessor.processAsync callbacks and an opt-in SentryOptions flag to run late event processing off the caller thread. Use a dedicated bounded queue for async callbacks, record queue overflow drops, and make flush/close drain accepted async work before downstream queues. Co-Authored-By: Claude <noreply@anthropic.com>
Contributor
|
📲 Install BuildsAndroid
|
Contributor
Performance metrics 🚀
|
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| a416a65 | 333.78 ms | 410.37 ms | 76.59 ms |
| d15471f | 304.55 ms | 408.43 ms | 103.87 ms |
| ca6b6d8 | 380.45 ms | 460.38 ms | 79.93 ms |
| c8125f3 | 397.65 ms | 485.14 ms | 87.49 ms |
| b936425 | 302.69 ms | 372.86 ms | 70.17 ms |
| ed33deb | 334.19 ms | 362.30 ms | 28.11 ms |
| cf708bd | 408.35 ms | 458.98 ms | 50.63 ms |
| eb95ded | 317.51 ms | 369.08 ms | 51.57 ms |
| a5ab36f | 320.47 ms | 389.77 ms | 69.30 ms |
| 80fd6ad | 321.06 ms | 375.79 ms | 54.73 ms |
App size
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| a416a65 | 1.58 MiB | 2.12 MiB | 555.26 KiB |
| d15471f | 1.58 MiB | 2.13 MiB | 559.54 KiB |
| ca6b6d8 | 0 B | 0 B | 0 B |
| c8125f3 | 1.58 MiB | 2.10 MiB | 532.32 KiB |
| b936425 | 0 B | 0 B | 0 B |
| ed33deb | 1.58 MiB | 2.13 MiB | 559.52 KiB |
| cf708bd | 1.58 MiB | 2.11 MiB | 539.71 KiB |
| eb95ded | 0 B | 0 B | 0 B |
| a5ab36f | 1.58 MiB | 2.12 MiB | 555.26 KiB |
| 80fd6ad | 0 B | 0 B | 0 B |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
📜 Description
Adds opt-in async event processing for SDK event capture paths.
This introduces
EventProcessor.processAsync(...)overloads for events, transactions, replay events, log events, and metrics events. WhenenableAsyncProcessingis enabled, late processing callbacks and before-send execution run through a dedicated bounded single-thread queue so capture calls can return after async work is accepted. The queue usesmaxQueueSize, reportsqueue_overflowon rejection, and returnsSentryId.EMPTY_IDfor ID-returning captures that cannot be queued.Also adds the external option key
enable-async-processing, flush/close draining behavior for async work, API updates, and a design note covering telemetry processor compatibility.💡 Motivation and Context
Some event processors and before-send callbacks can be expensive or user-defined. Running them on the capture caller thread can increase application latency. This feature keeps the existing synchronous behavior by default while allowing users to opt in to moving the late processing stage off the caller thread.
💚 How did you test it?
./gradlew spotlessApply apiDump./gradlew :sentry:test --tests 'io.sentry.SentryClientTest' --tests 'io.sentry.SentryOptionsTest' --tests 'io.sentry.ExternalOptionsTest'📝 Checklist
sendDefaultPIIis enabled.🔮 Next steps
Consider follow-up work to migrate selected SDK-owned expensive processors to
processAsync(...)where doing so does not capture stale request, thread-local, or UI state.