Skip to content
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

[SR] Session Replay #3339

Draft
wants to merge 159 commits into
base: main
Choose a base branch
from
Draft

[SR] Session Replay #3339

wants to merge 159 commits into from

Conversation

romtsn
Copy link
Member

@romtsn romtsn commented Apr 9, 2024

#skip-changelog

just to trigger CI for now

Comment on lines +43 to +95
override fun sendReplayForEvent(
isCrashed: Boolean,
eventId: String?,
hint: Hint?,
onSegmentSent: () -> Unit
) {
val sampled = random.sample(options.experimental.sessionReplay.errorSampleRate)

if (!sampled) {
options.logger.log(INFO, "Replay wasn't sampled by errorSampleRate, not capturing for event %s", eventId)
return
}

val errorReplayDuration = options.experimental.sessionReplay.errorReplayDuration
val now = dateProvider.currentTimeMillis
val currentSegmentTimestamp = if (cache?.frames?.isNotEmpty() == true) {
// in buffer mode we have to set the timestamp of the first frame as the actual start
DateUtils.getDateTime(cache!!.frames.first().timestamp)
} else {
DateUtils.getDateTime(now - errorReplayDuration)
}
val segmentId = currentSegment.get()
val replayId = currentReplayId.get()
val height = recorderConfig.recordingHeight
val width = recorderConfig.recordingWidth
replayExecutor.submitSafely(options, "$TAG.send_replay_for_event") {
var bufferedSegment = bufferedSegments.removeFirstOrNull()
while (bufferedSegment != null) {
// capture without hint, so the buffered segments don't trigger flush notification
bufferedSegment.capture(hub)
bufferedSegment = bufferedSegments.removeFirstOrNull()
Thread.sleep(100L)
}
val segment =
createSegment(
now - currentSegmentTimestamp.time,
currentSegmentTimestamp,
replayId,
segmentId,
height,
width,
BUFFER
)
if (segment is ReplaySegment.Created) {
segment.capture(hub, hint ?: Hint())

// we only want to increment segment_id in the case of success, but currentSegment
// might be irrelevant since we changed strategies, so in the callback we increment
// it on the new strategy already
onSegmentSent()
}
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is there a plan to use eventId here? AFAICT, event-replay mapping is done via trace context rather than any field. The argument here is used just for logging

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants