diff --git a/CHANGELOG.md b/CHANGELOG.md index b09266a3d9..7b9e746147 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -28,6 +28,7 @@ - Deprecate fields on the profiling sample format. ([#1878](https://github.com/getsentry/relay/pull/1878)) - Remove idle samples at the start and end of a profile and useless metadata. ([#1894](https://github.com/getsentry/relay/pull/1894)) - Move the pending envelopes buffering into the project cache. ([#1907](https://github.com/getsentry/relay/pull/1907)) +- Remove platform validation for profiles. ([#1933](https://github.com/getsentry/relay/pull/1933)) ## 23.2.0 diff --git a/relay-profiling/src/lib.rs b/relay-profiling/src/lib.rs index 93d0da7250..d3238c8181 100644 --- a/relay-profiling/src/lib.rs +++ b/relay-profiling/src/lib.rs @@ -93,7 +93,7 @@ //! } //! ``` -use serde::{Deserialize, Serialize}; +use serde::Deserialize; mod android; mod cocoa; @@ -113,24 +113,11 @@ pub use crate::error::ProfileError; pub use crate::outcomes::discard_reason; use crate::sample::{parse_sample_profile, Version}; -#[derive(Debug, Serialize, Deserialize, Clone)] -#[serde(rename_all = "lowercase")] -enum Platform { - Android, - Cocoa, - Dotnet, - Javascript, - Node, - Php, - Python, - Rust, -} - #[derive(Debug, Deserialize)] struct MinimalProfile { #[serde(alias = "profile_id")] event_id: EventId, - platform: Platform, + platform: String, #[serde(default)] version: Version, } @@ -146,9 +133,9 @@ pub fn expand_profile(payload: &[u8]) -> Result<(EventId, Vec), ProfileError }; let processed_payload = match profile.version { Version::V1 => parse_sample_profile(payload), - Version::Unknown => match profile.platform { - Platform::Android => parse_android_profile(payload), - Platform::Cocoa => parse_cocoa_profile(payload), + Version::Unknown => match profile.platform.as_str() { + "android" => parse_android_profile(payload), + "cocoa" => parse_cocoa_profile(payload), _ => return Err(ProfileError::PlatformNotSupported), }, }; diff --git a/relay-profiling/src/sample.rs b/relay-profiling/src/sample.rs index a291a1ff45..5ec8729d94 100644 --- a/relay-profiling/src/sample.rs +++ b/relay-profiling/src/sample.rs @@ -9,7 +9,6 @@ use crate::measurements::Measurement; use crate::native_debug_image::NativeDebugImage; use crate::transaction_metadata::TransactionMetadata; use crate::utils::deserialize_number_from_string; -use crate::Platform; #[derive(Debug, Serialize, Deserialize, Clone)] struct Frame { @@ -80,10 +79,10 @@ struct Profile { } impl Profile { - fn strip_pointer_authentication_code(&mut self, platform: &Platform, architecture: &str) { + fn strip_pointer_authentication_code(&mut self, platform: &str, architecture: &str) { let addr = match (platform, architecture) { // https://github.com/microsoft/plcrashreporter/blob/748087386cfc517936315c107f722b146b0ad1ab/Source/PLCrashAsyncThread_arm.c#L84 - (Platform::Cocoa, "arm64") | (Platform::Cocoa, "arm64e") => 0x0000000FFFFFFFFF, + ("cocoa", "arm64") | ("cocoa", "arm64e") => 0x0000000FFFFFFFFF, _ => return, }; for frame in &mut self.frames { @@ -150,7 +149,7 @@ struct SampleProfile { environment: String, #[serde(alias = "profile_id")] event_id: EventId, - platform: Platform, + platform: String, profile: Profile, release: String, timestamp: DateTime, @@ -166,19 +165,14 @@ struct SampleProfile { impl SampleProfile { fn valid(&self) -> bool { - match self.platform { - Platform::Cocoa => { + match self.platform.as_str() { + "cocoa" => { self.os.build_number.is_some() && self.device.is_emulator.is_some() && self.device.locale.is_some() && self.device.manufacturer.is_some() && self.device.model.is_some() } - Platform::Dotnet - | Platform::Javascript - | Platform::Node - | Platform::Php - | Platform::Python => self.runtime.is_some(), _ => true, } } @@ -365,7 +359,7 @@ mod tests { version: "16.0".to_string(), }, environment: "testing".to_string(), - platform: Platform::Cocoa, + platform: "cocoa".to_string(), event_id: EventId::new(), profile: Profile { queue_metadata: Some(HashMap::new()),