Skip to content

Commit

Permalink
feat(replays): Log event-id on replay-event (de)serialization failure (
Browse files Browse the repository at this point in the history
…#3221)

Closes: #3219

#skip-changelog
  • Loading branch information
cmanallen authored Mar 5, 2024
1 parent 67de702 commit edc7501
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions relay-server/src/services/processor/replay.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ pub fn process(
ItemType::ReplayEvent => {
match handle_replay_event_item(
item.payload(),
&event_id,
project_config,
client_addr,
user_agent,
Expand Down Expand Up @@ -120,6 +121,7 @@ pub fn process(

fn handle_replay_event_item(
payload: Bytes,
event_id: &Option<EventId>,
config: &ProjectConfig,
client_ip: Option<IpAddr>,
user_agent: &RawUserAgentInfo<&str>,
Expand All @@ -128,12 +130,20 @@ fn handle_replay_event_item(
Ok(replay) => match replay.to_json() {
Ok(json) => Ok(json.into_bytes().into()),
Err(error) => {
relay_log::error!(error = &error as &dyn Error, "failed to serialize replay");
relay_log::error!(
error = &error as &dyn Error,
?event_id,
"failed to serialize replay"
);
Ok(payload)
}
},
Err(error) => {
relay_log::warn!(error = &error as &dyn Error, "invalid replay event");
relay_log::warn!(
error = &error as &dyn Error,
?event_id,
"invalid replay event"
);
Err(Outcome::Invalid(match error {
ReplayError::NoContent => DiscardReason::InvalidReplayEventNoPayload,
ReplayError::CouldNotScrub(_) => DiscardReason::InvalidReplayEventPii,
Expand Down Expand Up @@ -242,7 +252,8 @@ fn handle_replay_video_item(
};

// Process as a replay-event envelope item.
let replay_event = handle_replay_event_item(replay_event, config, client_ip, user_agent)?;
let replay_event =
handle_replay_event_item(replay_event, event_id, config, client_ip, user_agent)?;

// Process as a replay-recording envelope item.
let replay_recording =
Expand Down

0 comments on commit edc7501

Please sign in to comment.