-
Notifications
You must be signed in to change notification settings - Fork 135
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
chore: skip rate limiting of snapshot events #1383
Merged
Merged
Changes from 2 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -863,15 +863,21 @@ export class SessionRecording { | |
} | ||
|
||
if (this.buffer.data.length > 0) { | ||
const snapshotEvents = splitBuffer(this.buffer) | ||
snapshotEvents.forEach((snapshotBuffer) => { | ||
this._captureSnapshot({ | ||
$snapshot_bytes: snapshotBuffer.size, | ||
$snapshot_data: snapshotBuffer.data, | ||
$session_id: snapshotBuffer.sessionId, | ||
$window_id: snapshotBuffer.windowId, | ||
const clientRateLimitContext = this.instance.rateLimiter.clientRateLimitContext() | ||
|
||
if (!clientRateLimitContext?.isRateLimited) { | ||
const snapshotEvents = splitBuffer(this.buffer) | ||
snapshotEvents.forEach((snapshotBuffer) => { | ||
this._captureSnapshot({ | ||
$snapshot_bytes: snapshotBuffer.size, | ||
$snapshot_data: snapshotBuffer.data, | ||
$session_id: snapshotBuffer.sessionId, | ||
$window_id: snapshotBuffer.windowId, | ||
}) | ||
}) | ||
}) | ||
} else { | ||
logger.critical('Cannot capture $snapshot event due to client rate limiting.') | ||
} | ||
} | ||
|
||
// buffer is empty, we clear it in case the session id has changed | ||
|
@@ -903,6 +909,7 @@ export class SessionRecording { | |
_url: this.instance.requestRouter.endpointFor('api', this._endpoint), | ||
_noTruncate: true, | ||
_batchKey: SESSION_RECORDING_BATCH_KEY, | ||
skip_client_rate_limiting: true, | ||
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. in the short term i think we should just get this line in i can't think of a problem caused by volume of snapshots that wasn't from a pre-batching version of the SDK so i think we can skip client rate limiting for replay and then figure out a good solution with the pressure off |
||
}) | ||
} | ||
|
||
|
Oops, something went wrong.
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.
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.
I thought this would get us the global bucket?
What I don't want (for example) is someone has an error in their code and exception autocapture rate limits because they're throwing in a loop
And then we can't capture a session recording.
I think we need to have a separate bucket for
$snapshot
events and a different rate limit for this - it's way chattier than other eventsUltimately I think we might want a separate bucket for errors but that can come with time.
I might be misunderstanding what's going on here ofc...
The benefit of client side rate limiting being event type aware would be it can pick the bucket and we don't need to change the recorder.
I'm picturing
or something equivalent to that so that we have a totally separate bucket.
equally you could make this endpoint aware so that it automatically has a different rate limit per endpoint
the other thing... this is pretty new... maybe the limits are wrong and that's the simplest fix is they should be a little higher so that replay doesn't trigger them
(Sorry brain dumping since i'll be afk for hours now :))