diff --git a/relay-event-normalization/src/replay.rs b/relay-event-normalization/src/replay.rs index ae72ecc20fb..ea1bab6a873 100644 --- a/relay-event-normalization/src/replay.rs +++ b/relay-event-normalization/src/replay.rs @@ -116,6 +116,9 @@ fn normalize_array_fields(replay: &mut Replay) { if let Some(items) = replay.urls.value_mut() { items.truncate(100); } + if let Some(items) = replay.segment_names.value_mut() { + items.truncate(100); + } } fn normalize_ip_address(replay: &mut Replay, ip_address: Option) { @@ -386,10 +389,15 @@ mod tests { .map(|_| Annotated::new(Uuid::parse_str("52df9022835246eeb317dbd739ccd059").unwrap())) .collect(); + let segment_names: Vec> = (0..101) + .map(|_| Annotated::new("/users/{id}".to_owned())) + .collect(); + let mut replay = Annotated::new(Replay { urls: Annotated::new(urls), error_ids: Annotated::new(error_ids), trace_ids: Annotated::new(trace_ids), + segment_names: Annotated::new(segment_names), ..Default::default() }); @@ -399,6 +407,7 @@ mod tests { assert!(replay_value.error_ids.value().unwrap().len() == 100); assert!(replay_value.trace_ids.value().unwrap().len() == 100); assert!(replay_value.urls.value().unwrap().len() == 100); + assert!(replay_value.segment_names.value().unwrap().len() == 100); } #[test] diff --git a/relay-event-schema/src/protocol/replay.rs b/relay-event-schema/src/protocol/replay.rs index b4a958225d2..57bbd923219 100644 --- a/relay-event-schema/src/protocol/replay.rs +++ b/relay-event-schema/src/protocol/replay.rs @@ -142,6 +142,10 @@ pub struct Replay { #[metastructure(max_depth = 5, max_bytes = 2048)] pub trace_ids: Annotated>, + /// A list of segment names discovered during the lifetime of the segment. + #[metastructure(pii = "true", max_depth = 5, max_bytes = 2048)] + pub segment_names: Annotated>, + /// Contexts describing the environment (e.g. device, os or browser). #[metastructure(skip_serialization = "empty")] pub contexts: Annotated, diff --git a/tests/integration/test_replay_combined_payload.py b/tests/integration/test_replay_combined_payload.py index c2a199b2f36..07c54f0d1dc 100644 --- a/tests/integration/test_replay_combined_payload.py +++ b/tests/integration/test_replay_combined_payload.py @@ -49,6 +49,10 @@ def test_replay_combined_with_processing( replay_event = json.loads(combined_replay_message["replay_event"]) assert replay_event["replay_id"] == replay_id + assert replay_event["segment_names"] == [ + "/api/0/organizations/", + "/api/0/projects/", + ] def test_standalone_recording_from_faulty_sdk( diff --git a/tests/integration/test_replay_events.py b/tests/integration/test_replay_events.py index 99bbae9459f..901d78b5513 100644 --- a/tests/integration/test_replay_events.py +++ b/tests/integration/test_replay_events.py @@ -19,6 +19,7 @@ def generate_replay_sdk_event(replay_id="d2132d31b39445f1938d7e21b6bf0ec4"): "urls": ["sentry.io"], "error_ids": [str(uuid.uuid4())], "trace_ids": [str(uuid.uuid4())], + "segment_names": ["/api/0/organizations/", "/api/0/projects/"], "dist": "1.12", "platform": "javascript", "environment": "production", @@ -61,6 +62,7 @@ def assert_replay_payload_matches(produced, consumed): assert consumed["urls"] == produced["urls"] assert consumed["error_ids"] == produced["error_ids"] assert consumed["trace_ids"] == produced["trace_ids"] + assert consumed["segment_names"] == produced["segment_names"] assert consumed["dist"] == produced["dist"] assert consumed["platform"] == produced["platform"] assert consumed["environment"] == produced["environment"]