Skip to content

Commit 6ec6039

Browse files
cmanallenJoshFergejjbayer
authored
feat(replays): Add ReplayVideo envelope item type (#3105)
Add support for replay-video event types. Changes: - Refactors event validation in the processor. This is to DRY the processing logic between the three replay event types. - Adds new replay_video field to replay-recording Kafka message. - Add outcomes. - Configure rate-limits. Relates to: * getsentry/sentry#63255 --------- Co-authored-by: Joshua Ferge <[email protected]> Co-authored-by: Josh Ferge <[email protected]> Co-authored-by: Joris Bayer <[email protected]>
1 parent dc6ece7 commit 6ec6039

File tree

15 files changed

+437
-202
lines changed

15 files changed

+437
-202
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
- Extend GPU context with data for Unreal Engine crash reports. ([#3144](https://github.com/getsentry/relay/pull/3144))
88
- Parametrize transaction in dynamic sampling context. ([#3141](https://github.com/getsentry/relay/pull/3141))
9+
- Adds ReplayVideo envelope-item type. ([#3105](https://github.com/getsentry/relay/pull/3105))
910
- Parse & scrub span description for supabase. ([#3153](https://github.com/getsentry/relay/pull/3153), [#3156](https://github.com/getsentry/relay/pull/3156))
1011

1112
**Bug Fixes**:

Cargo.lock

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

relay-replays/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ license-file = "../LICENSE.md"
1010
publish = false
1111

1212
[dependencies]
13+
bytes = { version = "1.4.0" }
1314
flate2 = "1.0.19"
1415
once_cell = { workspace = true }
1516
relay-common = { path = "../relay-common" }

relay-server/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ processing = [
2323
"dep:symbolic-common",
2424
"dep:symbolic-unreal",
2525
"dep:zstd",
26-
"bytes/serde",
2726
"relay-cardinality/redis",
2827
"relay-config/processing",
2928
"relay-kafka/producer",
@@ -47,7 +46,7 @@ axum-server = "0.4.7"
4746
backoff = "0.4.0"
4847
brotli = "3.3.4"
4948
bytecount = "0.6.0"
50-
bytes = { version = "1.4.0" }
49+
bytes = { version = "1.4.0", features = ["serde"] }
5150
chrono = { workspace = true, features = ["clock"] }
5251
data-encoding = "2.3.3"
5352
flate2 = "1.0.19"
@@ -97,6 +96,7 @@ reqwest = { version = "0.11.1", features = [
9796
rmp-serde = "1.1.1"
9897
rust-embed = { version = "8.0.0", optional = true }
9998
serde = { workspace = true }
99+
serde_bytes = "0.11"
100100
serde_json = { workspace = true }
101101
smallvec = { workspace = true, features = ["drain_filter"] }
102102
sqlx = { version = "0.7.3", features = [

relay-server/src/envelope.rs

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,8 @@ pub enum ItemType {
114114
ReplayEvent,
115115
/// Replay Recording data.
116116
ReplayRecording,
117+
/// Replay Video data.
118+
ReplayVideo,
117119
/// Monitor check-in encoded as JSON.
118120
CheckIn,
119121
/// A standalone span.
@@ -168,6 +170,7 @@ impl ItemType {
168170
Self::Profile => "profile",
169171
Self::ReplayEvent => "replay_event",
170172
Self::ReplayRecording => "replay_recording",
173+
Self::ReplayVideo => "replay_video",
171174
Self::CheckIn => "check_in",
172175
Self::Span => "span",
173176
Self::OtelSpan => "otel_span",
@@ -222,6 +225,7 @@ impl std::str::FromStr for ItemType {
222225
"profile" => Self::Profile,
223226
"replay_event" => Self::ReplayEvent,
224227
"replay_recording" => Self::ReplayRecording,
228+
"replay_video" => Self::ReplayVideo,
225229
"check_in" => Self::CheckIn,
226230
"span" => Self::Span,
227231
"otel_span" => Self::OtelSpan,
@@ -661,7 +665,9 @@ impl Item {
661665
} else {
662666
DataCategory::Profile
663667
}),
664-
ItemType::ReplayEvent | ItemType::ReplayRecording => Some(DataCategory::Replay),
668+
ItemType::ReplayEvent | ItemType::ReplayRecording | ItemType::ReplayVideo => {
669+
Some(DataCategory::Replay)
670+
}
665671
ItemType::ClientReport => None,
666672
ItemType::CheckIn => Some(DataCategory::Monitor),
667673
ItemType::Span | ItemType::OtelSpan => Some(if indexed {
@@ -873,6 +879,7 @@ impl Item {
873879
| ItemType::ClientReport
874880
| ItemType::ReplayEvent
875881
| ItemType::ReplayRecording
882+
| ItemType::ReplayVideo
876883
| ItemType::Profile
877884
| ItemType::CheckIn
878885
| ItemType::Span
@@ -907,6 +914,7 @@ impl Item {
907914
ItemType::MetricMeta => false,
908915
ItemType::ClientReport => false,
909916
ItemType::ReplayRecording => false,
917+
ItemType::ReplayVideo => false,
910918
ItemType::Profile => true,
911919
ItemType::CheckIn => false,
912920
ItemType::Span => false,
@@ -1765,6 +1773,22 @@ mod tests {
17651773
assert_eq!(items[0].ty(), &ItemType::ReplayRecording);
17661774
}
17671775

1776+
#[test]
1777+
fn test_deserialize_envelope_replay_video() {
1778+
let bytes = Bytes::from(
1779+
"\
1780+
{\"event_id\":\"9ec79c33ec9942ab8353589fcb2e04dc\",\"dsn\":\"https://e12d836b15bb49d7bbf99e64295d995b:@sentry.io/42\"}\n\
1781+
{\"type\":\"replay_video\"}\n\
1782+
helloworld\n\
1783+
",
1784+
);
1785+
1786+
let envelope = Envelope::parse_bytes(bytes).unwrap();
1787+
assert_eq!(envelope.len(), 1);
1788+
let items: Vec<_> = envelope.items().collect();
1789+
assert_eq!(items[0].ty(), &ItemType::ReplayVideo);
1790+
}
1791+
17681792
#[test]
17691793
fn test_deserialize_envelope_view_hierarchy() {
17701794
let bytes = Bytes::from(

relay-server/src/services/outcome.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,7 @@ pub enum DiscardReason {
366366
InvalidReplayEventNoPayload,
367367
InvalidReplayEventPii,
368368
InvalidReplayRecordingEvent,
369+
InvalidReplayVideoEvent,
369370

370371
/// (Relay) Profiling related discard reasons
371372
Profiling(&'static str),
@@ -413,6 +414,7 @@ impl DiscardReason {
413414
DiscardReason::InvalidReplayEventNoPayload => "invalid_replay_no_payload",
414415
DiscardReason::InvalidReplayEventPii => "invalid_replay_pii_scrubber_failed",
415416
DiscardReason::InvalidReplayRecordingEvent => "invalid_replay_recording",
417+
DiscardReason::InvalidReplayVideoEvent => "invalid_replay_video",
416418
DiscardReason::Profiling(reason) => reason,
417419
DiscardReason::InvalidSpan => "invalid_span",
418420
}

relay-server/src/services/processor.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ impl ProcessingGroup {
226226
let replay_items = envelope.take_items_by(|item| {
227227
matches!(
228228
item.ty(),
229-
&ItemType::ReplayEvent | &ItemType::ReplayRecording
229+
&ItemType::ReplayEvent | &ItemType::ReplayRecording | &ItemType::ReplayVideo
230230
)
231231
});
232232
if !replay_items.is_empty() {

relay-server/src/services/processor/event.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -464,6 +464,7 @@ fn is_duplicate(item: &Item, processing_enabled: bool) -> bool {
464464
ItemType::Profile => false,
465465
ItemType::ReplayEvent => false,
466466
ItemType::ReplayRecording => false,
467+
ItemType::ReplayVideo => false,
467468
ItemType::CheckIn => false,
468469
ItemType::Span => false,
469470
ItemType::OtelSpan => false,

0 commit comments

Comments
 (0)