Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ref(profiling): Remove platform validation #1933

Merged
merged 2 commits into from
Mar 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
23 changes: 5 additions & 18 deletions relay-profiling/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@
//! }
//! ```

use serde::{Deserialize, Serialize};
use serde::Deserialize;

mod android;
mod cocoa;
Expand All @@ -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,
}
Expand All @@ -146,9 +133,9 @@ pub fn expand_profile(payload: &[u8]) -> Result<(EventId, Vec<u8>), 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),
},
};
Expand Down
18 changes: 6 additions & 12 deletions relay-profiling/src/sample.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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<Utc>,
Expand All @@ -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,
}
}
Expand Down Expand Up @@ -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()),
Expand Down