Skip to content

Commit

Permalink
feat(replays): Record too long discard reason (#3950)
Browse files Browse the repository at this point in the history
When a replay exceeds the segment limit we should report that and make
it viewable in the stats interface.

---------

Co-authored-by: Joris Bayer <joris.bayer@sentry.io>
  • Loading branch information
cmanallen and jjbayer committed Aug 27, 2024
1 parent cce218f commit 7bd2c99
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@

- Keep frames from both ends of the stacktrace when trimming frames. ([#3905](https://github.com/getsentry/relay/pull/3905))

**Internal**:

- Record too long discard reason for session replays. ([#3950](https://github.com/getsentry/relay/pull/3950))

**Features**:

- Add configuration option to specify the instance type of Relay. ([#3938](https://github.com/getsentry/relay/pull/3938))
Expand Down
10 changes: 7 additions & 3 deletions relay-event-normalization/src/replay.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ pub enum ReplayError {
#[error("invalid payload {0}")]
InvalidPayload(String),

/// The Replay has consumed its segment limit.
///
/// This is returned from [`validate`].
#[error("invalid replay length")]
TooLong,

/// An error occurred during PII scrubbing of the Replay.
///
/// This erorr is usually returned when the PII configuration fails to parse.
Expand Down Expand Up @@ -56,9 +62,7 @@ pub fn validate(replay: &Replay) -> Result<(), ReplayError> {
const MAX_SEGMENT_ID: u64 = 60 * 60 / 5;

if segment_id > MAX_SEGMENT_ID {
return Err(ReplayError::InvalidPayload(
"segment_id limit exceeded".to_string(),
));
return Err(ReplayError::TooLong);
}

if replay
Expand Down
2 changes: 2 additions & 0 deletions relay-server/src/services/outcome.rs
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,7 @@ pub enum DiscardReason {
InvalidReplayEventPii,
InvalidReplayRecordingEvent,
InvalidReplayVideoEvent,
ReplayExceededSegmentLimit,

/// (Relay) Profiling related discard reasons
Profiling(&'static str),
Expand Down Expand Up @@ -500,6 +501,7 @@ impl DiscardReason {
DiscardReason::InvalidReplayEventPii => "invalid_replay_pii_scrubber_failed",
DiscardReason::InvalidReplayRecordingEvent => "invalid_replay_recording",
DiscardReason::InvalidReplayVideoEvent => "invalid_replay_video",
DiscardReason::ReplayExceededSegmentLimit => "replay_segment_limit_exceeded",
DiscardReason::Profiling(reason) => reason,
DiscardReason::InvalidSpan => "invalid_span",
DiscardReason::FeatureDisabled(_) => "feature_disabled",
Expand Down
3 changes: 3 additions & 0 deletions relay-server/src/services/processor/replay.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,9 @@ fn handle_replay_event_item(
ReplayError::InvalidPayload(_) => {
ProcessingError::InvalidReplay(DiscardReason::InvalidReplayEvent)
}
ReplayError::TooLong => {
ProcessingError::InvalidReplay(DiscardReason::ReplayExceededSegmentLimit)
}
})
}
}
Expand Down

0 comments on commit 7bd2c99

Please sign in to comment.