-
-
Notifications
You must be signed in to change notification settings - Fork 476
fix(replay): Skip buffer-mode replay capture when rate-limited (DART-313) #5813
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,6 +4,8 @@ import android.annotation.SuppressLint | |
| import android.annotation.TargetApi | ||
| import android.graphics.Bitmap | ||
| import android.view.MotionEvent | ||
| import io.sentry.DataCategory.All | ||
| import io.sentry.DataCategory.Replay | ||
| import io.sentry.DateUtils | ||
| import io.sentry.IScopes | ||
| import io.sentry.SentryLevel.DEBUG | ||
|
|
@@ -76,6 +78,13 @@ internal class BufferCaptureStrategy( | |
| } | ||
|
|
||
| override fun captureReplay(isTerminating: Boolean, onSegmentSent: (Date) -> Unit) { | ||
| if (isReplayRateLimited()) { | ||
| // the segment envelopes would be dropped by the transport anyway, so don't waste resources | ||
| // encoding videos that will only be discarded | ||
| options.logger.log(INFO, "Replay is rate-limited, not capturing for event") | ||
| return | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| } | ||
|
|
||
| val sampled = random.sample(options.sessionReplay.onErrorSampleRate) | ||
|
|
||
| if (!sampled) { | ||
|
|
@@ -170,6 +179,11 @@ internal class BufferCaptureStrategy( | |
| rotateEvents(currentEvents, bufferLimit) | ||
| } | ||
|
|
||
| private fun isReplayRateLimited(): Boolean = | ||
| scopes?.rateLimiter?.let { | ||
| it.isActiveForCategory(All) || it.isActiveForCategory(Replay) | ||
| } == true | ||
|
|
||
| private fun deleteFile(file: File?) { | ||
| if (file == null) { | ||
| return | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
h: I think we're calling this a bit early -- should likely do it after theif (isTerminating)check, otherwise we'd be dropping replays for crashed events (which are anyway not being sent in this process, but only on next launch, where the rate limit likely will have already been lifted).Another side effect of not setting
isTerminatingwould be that the followingconvert()call would convert to session mode and try to keep recording while the process is terminating. Probs, needs a test for this to not regress in the future too