-
Notifications
You must be signed in to change notification settings - Fork 3
refactor: O11Y-904 - Session replay to use event queue and batch worker #343
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Conversation
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
Replaces OpenTelemetry log-based session replay export with a new event queue and batch worker system. Introduces transport layer abstractions (EventQueue, BatchWorker, EventExporting, etc.) and payload types for images, interactions, and identify events. Updates ReplayInstrumentation and SessionReplayExporter to use the new transport, improving batching, error handling, and extensibility. Updates tests to use the new event queue item types.
...droid/lib/src/main/kotlin/com/launchdarkly/observability/replay/transport/FlushableWorker.kt
Show resolved
Hide resolved
...y-android/lib/src/main/kotlin/com/launchdarkly/observability/replay/transport/BatchWorker.kt
Outdated
Show resolved
Hide resolved
...y-android/lib/src/main/kotlin/com/launchdarkly/observability/replay/transport/BatchWorker.kt
Outdated
Show resolved
Hide resolved
...y-android/lib/src/main/kotlin/com/launchdarkly/observability/replay/transport/BatchWorker.kt
Outdated
Show resolved
Hide resolved
...y-android/lib/src/main/kotlin/com/launchdarkly/observability/replay/transport/BatchWorker.kt
Outdated
Show resolved
Hide resolved
...droid/lib/src/main/kotlin/com/launchdarkly/observability/replay/transport/FlushableWorker.kt
Show resolved
Hide resolved
Added synchronized blocks to start, stop, and flush methods in BatchWorker and FlushableWorker to ensure thread safety. Replaced System.currentTimeMillis() with SystemClock.elapsedRealtime() for more accurate timing. Improved error handling in BatchWorker by catching Throwable instead of Exception, and refactored internal state snapshot naming for clarity.
...ty-android/lib/src/main/kotlin/com/launchdarkly/observability/replay/transport/EventQueue.kt
Outdated
Show resolved
Hide resolved
Introduces comprehensive tests for the FlushableWorker class
abelonogov-ld
approved these changes
Jan 13, 2026
- Add tests for BatchWorker and EventQueue - Refactor send() function in EventQueue to avoid acquiring the lock multiple times when it is called from send(payloads) and rename to sendLocked() - Rename EventQueue constructor params replacing "size" word by "cost" - Add docs to earliest and removeFirst functions
e2e/android/app/src/main/java/com/example/androidobservability/BaseApplication.kt
Outdated
Show resolved
Hide resolved
...ty-android/lib/src/main/kotlin/com/launchdarkly/observability/replay/transport/EventQueue.kt
Show resolved
Hide resolved
Avoids dropping the first item when the queue is empty, matching the total cost check and reducing silent data loss.
.../lib/src/main/kotlin/com/launchdarkly/observability/replay/exporter/SessionReplayExporter.kt
Show resolved
Hide resolved
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.
Summary
Replaces OpenTelemetry log-based session replay export with a new event queue and batch worker system. Introduces transport layer abstractions (EventQueue, BatchWorker, EventExporting, etc.) and payload types for images, interactions, and identify events. Updates ReplayInstrumentation and SessionReplayExporter to use the new transport, improving batching, error handling, and extensibility. Updates tests to use the new event queue item types.
How did you test this change?
Unit tests
Note
Re-architects session replay transport for reliability and extensibility.
EventQueue,BatchWorker(interval-driven, flush, backoff/jitter, concurrency limits),FlushableWorker, andEventExportingAPIImageItemPayload,InteractionItemPayload, and updatesIdentifyItemPayloadto implementEventQueueItemPayloadwith cost/timestamp/exporter metadataSessionReplayExportertoEventExportingwithexport(List<EventQueueItem>), internal RRWeb event generation moved off OTel logs; groups by session, initializes sessions, and pushes payloads; extracts capture handling intohandleCaptureReplayInstrumentationto enqueue events and driveBatchWorker(start/stop/flush on lifecycle), logs downgraded todebugactivityLifecycleEventQueue,BatchWorker,FlushableWorker)Written by Cursor Bugbot for commit 22b1b0a. This will update automatically on new commits. Configure here.