Skip to content

Commit 11666ec

Browse files
runningcodeclaude
andauthored
docs(replay): Document the two capture strategies (#5848)
SessionCaptureStrategy and BufferCaptureStrategy differ only in when a recorded segment is sent, but nothing at the top of either class said so. Add a short KDoc to each pointing at the other, covering how the mode is selected, when segments are sent, and why ReplayIntegration pauses session mode while buffer mode keeps recording. Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
1 parent 02b196f commit 11666ec

2 files changed

Lines changed: 23 additions & 0 deletions

File tree

‎sentry-android-replay/src/main/java/io/sentry/android/replay/capture/BufferCaptureStrategy.kt‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,18 @@ import java.io.File
2828
import java.util.Date
2929
import java.util.concurrent.ScheduledExecutorService
3030

31+
/**
32+
* Records a rolling `errorReplayDuration` window: segments are encoded but held in memory, and
33+
* frames and segments older than the window are dropped on every screenshot. Used when the session
34+
* is not sampled by `sessionSampleRate` but `onErrorSampleRate` is set.
35+
*
36+
* Nothing is sent until [captureReplay] flushes the buffer for an error — sampled per error against
37+
* `onErrorSampleRate`, unlike session mode which samples once at start. After a successful flush
38+
* [convert] hands over to a [SessionCaptureStrategy] so the rest of the session is recorded live.
39+
*
40+
* Since nothing is in flight, `ReplayIntegration` deliberately keeps this strategy recording while
41+
* rate-limited, so the buffer stays warm for when the limit expires.
42+
*/
3143
@SuppressLint("UseRequiresApi")
3244
@TargetApi(26)
3345
internal class BufferCaptureStrategy(

‎sentry-android-replay/src/main/java/io/sentry/android/replay/capture/SessionCaptureStrategy.kt‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,17 @@ import io.sentry.util.FileUtils
1616
import java.util.Date
1717
import java.util.concurrent.ScheduledExecutorService
1818

19+
/**
20+
* Records a full session: segments are encoded and sent continuously, one per
21+
* `sessionSegmentDuration`, until the 1h `sessionDuration` deadline. Used when the session is
22+
* sampled by `sessionSampleRate`.
23+
*
24+
* [captureReplay] is a no-op here — there is no buffer to flush, the segment covering the error is
25+
* sent like any other. Because envelopes are in flight the whole time, `ReplayIntegration` pauses
26+
* this strategy while offline or rate-limited so the envelope cache doesn't overflow.
27+
*
28+
* See [BufferCaptureStrategy] for the on-error counterpart.
29+
*/
1930
internal class SessionCaptureStrategy(
2031
private val options: SentryOptions,
2132
private val scopes: IScopes?,

0 commit comments

Comments
 (0)