Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into dav1d/sypc
Browse files Browse the repository at this point in the history
  • Loading branch information
Dav1dde committed Oct 30, 2024
2 parents 4fd4839 + 733363d commit b166101
Show file tree
Hide file tree
Showing 69 changed files with 23,856 additions and 518 deletions.
18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,23 @@
- Removes support for metric meta envelope items. ([#4152](https://github.com/getsentry/relay/pull/4152))
- Removes support for the project cache endpoint version 2 and before. ([#4147](https://github.com/getsentry/relay/pull/4147))

**Bug Fixes**

- Allow profile chunks without release. ([#4155](https://github.com/getsentry/relay/pull/4155))
- Add validation for timestamps sent from the future. ([#4163](https://github.com/getsentry/relay/pull/4163))

**Features:**

- Retain empty string values in `span.data` and `event.contexts.trace.data`. ([#4174](https://github.com/getsentry/relay/pull/4174))
- Allow `sample_rate` to be float type when deserializing `DynamicSamplingContext`. ([#4181](https://github.com/getsentry/relay/pull/4181))
- Support inbound filters for profiles. ([#4176](https://github.com/getsentry/relay/pull/4176))

**Internal:**

- Add a metric that counts span volume in the root project for dynamic sampling (`c:spans/count_per_root_project@none`). ([#4134](https://github.com/getsentry/relay/pull/4134))
- Add a tag `target_project_id` to both root project metrics for dynamic sampling (`c:transactions/count_per_root_project@none` and `c:spans/count_per_root_project@none`) which shows the flow trace traffic from root to target projects. ([#4170](https://github.com/getsentry/relay/pull/4170))
- Use `DateTime<Utc>` instead of `Instant` for tracking the received time of the `Envelope`. ([#4184](https://github.com/getsentry/relay/pull/4184))

## 24.10.0

**Breaking Changes**:
Expand All @@ -27,6 +44,7 @@
- Add user geo information to Replays. ([#4088](https://github.com/getsentry/relay/pull/4088))
- Configurable span.op inference. ([#4056](https://github.com/getsentry/relay/pull/4056))
- Enable support for zstd `Content-Encoding`. ([#4089](https://github.com/getsentry/relay/pull/4089))
- Accept profile chunks from Android. ([#4104](https://github.com/getsentry/relay/pull/4104))
- Add support for creating User from LoginId in Unreal Crash Context. ([#4093](https://github.com/getsentry/relay/pull/4093))
- Add multi-write Redis client. ([#4064](https://github.com/getsentry/relay/pull/4064))

Expand Down
18 changes: 18 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ for more information.

## Development

To build Relay, we require the **latest stable Rust**. The crate is split into a
To build Relay, we require the **latest stable Rust** (install via [rustup](https://rustup.rs/)). The crate is split into a
workspace with multiple features, so when running building or running tests
always make sure to pass the `--all` and `--all-features` flags.
The `processing` feature additionally requires a C compiler and CMake.
Expand Down Expand Up @@ -75,6 +75,9 @@ Depending on the configuration, you may need to have a local instance of Sentry
running.

```bash
# Update rust
rustup update

# Initialize Relay for the first time
cargo run --all-features -- config init

Expand Down
4 changes: 4 additions & 0 deletions gocd/templates/pipelines/pops.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ local canary_region_pops = {
'us-pop-regional-2',
'us-pop-regional-3',
'us-pop-regional-4',
'us-pop-1',
'us-pop-2',
],
};

Expand All @@ -24,6 +26,8 @@ local region_pops = {
'us-pop-regional-2',
'us-pop-regional-3',
'us-pop-regional-4',
'us-pop-1',
'us-pop-2',
],
s4s: [],
};
Expand Down
5 changes: 0 additions & 5 deletions relay-common/src/time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,6 @@ pub fn instant_to_system_time(instant: Instant) -> SystemTime {
SystemTime::now() - instant.elapsed()
}

/// Converts an `Instant` into a `DateTime`.
pub fn instant_to_date_time(instant: Instant) -> chrono::DateTime<chrono::Utc> {
instant_to_system_time(instant).into()
}

/// Returns the number of milliseconds contained by this `Duration` as `f64`.
///
/// The returned value does include the fractional (nanosecond) part of the duration.
Expand Down
49 changes: 48 additions & 1 deletion relay-event-normalization/src/replay.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
//! Validation and normalization of [`Replay`] events.
use chrono::Utc;
use std::net::IpAddr as StdIpAddr;

use relay_event_schema::processor::{self, ProcessingState, Processor};
Expand Down Expand Up @@ -35,6 +36,10 @@ pub enum ReplayError {
/// This erorr is usually returned when the PII configuration fails to parse.
#[error("failed to scrub PII: {0}")]
CouldNotScrub(String),

/// Date in the future.
#[error("date was from the future")]
DateInTheFuture,
}

/// Checks if the Replay event is structurally valid.
Expand Down Expand Up @@ -76,6 +81,14 @@ pub fn validate(replay: &Replay) -> Result<(), ReplayError> {
));
}

if replay
.timestamp
.value()
.map_or(false, |v| v.into_inner() > Utc::now())
{
return Err(ReplayError::DateInTheFuture);
}

Ok(())
}

Expand Down Expand Up @@ -171,7 +184,7 @@ fn normalize_type(replay: &mut Replay) {
mod tests {
use std::net::{IpAddr, Ipv4Addr};

use chrono::{TimeZone, Utc};
use chrono::{Duration, TimeZone, Utc};
use insta::assert_json_snapshot;
use relay_protocol::{assert_annotated_snapshot, get_value, SerializableAnnotated};
use uuid::Uuid;
Expand Down Expand Up @@ -439,6 +452,40 @@ mod tests {
assert!(validation_result.is_err());
}

#[test]
fn test_future_timestamp_validation() {
let future_time = Utc::now() + Duration::hours(1);
let json = format!(
r#"{{
"event_id": "52df9022835246eeb317dbd739ccd059",
"replay_id": "52df9022835246eeb317dbd739ccd059",
"segment_id": 0,
"replay_type": "session",
"error_sample_rate": 0.5,
"session_sample_rate": 0.5,
"timestamp": {},
"replay_start_timestamp": 946684800.0,
"urls": ["localhost:9000"],
"error_ids": ["test"],
"trace_ids": [],
"platform": "myplatform",
"release": "myrelease",
"dist": "mydist",
"environment": "myenv",
"tags": [
[
"tag",
"value"
]
]
}}"#,
future_time.timestamp()
);
let mut replay = Annotated::<Replay>::from_json(&json).unwrap();
let validation_result = validate(replay.value_mut().as_mut().unwrap());
assert!(validation_result.is_err());
}

#[test]
fn test_trace_id_validation() {
// NOTE: Interfaces will be tested separately.
Expand Down
21 changes: 11 additions & 10 deletions relay-event-schema/src/protocol/contexts/trace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ pub struct TraceContext {
pub sampled: Annotated<bool>,

/// Data of the trace's root span.
#[metastructure(pii = "maybe", skip_serialization = "empty")]
#[metastructure(pii = "maybe", skip_serialization = "null")]
pub data: Annotated<SpanData>,

/// Additional arbitrary fields for forwards compatibility.
Expand Down Expand Up @@ -197,7 +197,8 @@ mod tests {
"tok": "test"
},
"custom_field": "something"
}
},
"custom_field_empty": ""
},
"other": "value",
"type": "trace"
Expand All @@ -222,15 +223,15 @@ mod tests {
);
map
}),
other: {
let mut map = Object::new();
map.insert(
"custom_field".into(),
Annotated::new(Value::String("something".into())),
);
map
},
other: Object::from([(
"custom_field".into(),
Annotated::new(Value::String("something".into())),
)]),
}),
other: Object::from([(
"custom_field_empty".into(),
Annotated::new(Value::String("".into())),
)]),
..Default::default()
}),
other: {
Expand Down
36 changes: 35 additions & 1 deletion relay-event-schema/src/protocol/span.rs
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,7 @@ pub struct SpanData {
additional_properties,
pii = "true",
retain = "true",
skip_serialization = "empty"
skip_serialization = "null" // applies to child elements
)]
pub other: Object<Value>,
}
Expand Down Expand Up @@ -931,4 +931,38 @@ mod tests {
assert_eq!(data.get_value("code\\.namespace"), Some(Val::String("ns")));
assert_eq!(data.get_value("unknown"), None);
}

#[test]
fn test_span_data_empty_well_known_field() {
let span = r#"{
"data": {
"lcp.url": ""
}
}"#;
let span: Annotated<Span> = Annotated::from_json(span).unwrap();
assert_eq!(span.to_json().unwrap(), r#"{"data":{"lcp.url":""}}"#);
}

#[test]
fn test_span_data_empty_custom_field() {
let span = r#"{
"data": {
"custom_field_empty": ""
}
}"#;
let span: Annotated<Span> = Annotated::from_json(span).unwrap();
assert_eq!(
span.to_json().unwrap(),
r#"{"data":{"custom_field_empty":""}}"#
);
}

#[test]
fn test_span_data_completely_empty() {
let span = r#"{
"data": {}
}"#;
let span: Annotated<Span> = Annotated::from_json(span).unwrap();
assert_eq!(span.to_json().unwrap(), r#"{"data":{}}"#);
}
}
3 changes: 3 additions & 0 deletions relay-profiling/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,17 @@ chrono = { workspace = true }
data-encoding = { workspace = true }
itertools = { workspace = true }
relay-base-schema = { workspace = true }
relay-dynamic-config = { workspace = true }
relay-event-schema = { workspace = true }
relay-filter = { workspace = true }
relay-log = { workspace = true }
relay-metrics = { workspace = true }
relay-protocol = { workspace = true }
serde = { workspace = true }
serde_json = { workspace = true }
serde_path_to_error = { workspace = true }
thiserror = { workspace = true }
url = { workspace = true }

[dev-dependencies]
insta = { workspace = true }
Loading

0 comments on commit b166101

Please sign in to comment.