Skip to content

Commit

Permalink
feat(replays): Add sample rate fields (#1745)
Browse files Browse the repository at this point in the history
  • Loading branch information
cmanallen authored Jan 18, 2023
1 parent a30b6d6 commit 229b7c3
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 0 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## Unreleased

**Features**:

- Add error and sample rate fields to the replay event parser. ([#1745](https://github.com/getsentry/relay/pull/1745))

## 23.1.0

**Features**:
Expand Down
28 changes: 28 additions & 0 deletions relay-general/src/protocol/replay.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,28 @@ pub struct Replay {
/// ```
pub replay_type: Annotated<String>,

/// The sample rate used to make a recording decision when an error has been detected.
///
/// Example:
///
/// ```json
/// {
/// "error_sample_rate": 0.75
/// }
/// ```
pub error_sample_rate: Annotated<f64>,

/// The sample rate used to make a recording decision
///
/// Example:
///
/// ```json
/// {
/// "session_sample_rate": 0.125
/// }
/// ```
pub session_sample_rate: Annotated<f64>,

/// Segment identifier.
///
/// A number representing a unique segment identifier in the chain of replay segments.
Expand Down Expand Up @@ -346,6 +368,9 @@ mod tests {
"event_id": "52df9022835246eeb317dbd739ccd059",
"replay_id": "52df9022835246eeb317dbd739ccd059",
"segment_id": 0,
"replay_type": "session",
"error_sample_rate": 0.5,
"session_sample_rate": 0.5,
"timestamp": 946684800.0,
"replay_start_timestamp": 946684800.0,
"urls": ["localhost:9000"],
Expand All @@ -370,6 +395,9 @@ mod tests {
replay_id: Annotated::new(EventId(
uuid::Uuid::parse_str("52df9022835246eeb317dbd739ccd059").unwrap(),
)),
replay_type: Annotated::new("session".to_string()),
error_sample_rate: Annotated::new(0.5),
session_sample_rate: Annotated::new(0.5),
segment_id: Annotated::new(0),
timestamp: Annotated::new(Utc.ymd(2000, 1, 1).and_hms(0, 0, 0).into()),
replay_start_timestamp: Annotated::new(Utc.ymd(2000, 1, 1).and_hms(0, 0, 0).into()),
Expand Down
4 changes: 4 additions & 0 deletions tests/integration/test_replay_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ def generate_replay_sdk_event():
"type": "replay_event",
"replay_id": "d2132d31b39445f1938d7e21b6bf0ec4",
"replay_type": "session",
"error_sample_rate": 0.125,
"session_sample_rate": 0.5,
"event_id": "d2132d31b39445f1938d7e21b6bf0ec4",
"segment_id": 0,
"timestamp": 1597977777.6189718,
Expand Down Expand Up @@ -63,6 +65,8 @@ def test_replay_event_with_processing(
# Assert required fields were returned.
assert parsed_replay["replay_id"] == replay["replay_id"]
assert parsed_replay["replay_type"] == replay["replay_type"]
assert parsed_replay["error_sample_rate"] == replay["error_sample_rate"]
assert parsed_replay["session_sample_rate"] == replay["session_sample_rate"]
assert parsed_replay["event_id"] == replay["event_id"]
assert parsed_replay["type"] == replay["type"]
assert parsed_replay["segment_id"] == replay["segment_id"]
Expand Down

0 comments on commit 229b7c3

Please sign in to comment.