-
Notifications
You must be signed in to change notification settings - Fork 93
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
feat(profile): Introduce a common sample format #1462
Merged
Merged
Changes from 7 commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
f2bb0bc
feat(profile): Introduce a common sample format
phacops 81561f1
Remove unnecessary code
phacops edd820d
Support frame indexing
phacops 07923cc
Support frames without addresses
phacops e1221c3
Add a changelog entry
phacops b49c885
Merge branch 'master' into pierre/profiling-sample-format
phacops c5b8146
Use more efficient syntax where suggested
phacops 08e1210
Add a thread_id field to the transaction metadata to collect the thre…
phacops ab0f69c
Merge branch 'master' into pierre/profiling-sample-format
phacops d6048d5
Generate a new event_id when duplicating the profile
phacops 20c33ba
Avoid potential panic if end < start
phacops b3fc60e
Match on specific version instead of just testing for existence
phacops ce2f060
Do not filter frames or stacks since they are indexed
phacops af1de3b
Explain why we're duplicating profiles
phacops fdae8a7
Adjust some types
phacops 9adabfe
Do not serialize zero values
phacops 9661180
Rename field to clarify its use
phacops cfb397f
Merge branch 'master' into pierre/profiling-sample-format
phacops 760a62a
Merge branch 'master' into pierre/profiling-sample-format
phacops 895c195
Rename a field for clarity
phacops 77e5b01
Rename key in test data as well
phacops b4af3bc
Merge branch 'master' into pierre/profiling-sample-format
phacops 0601e39
Remove check for thread_id since nodejs thread IDs can be equal to 0
phacops File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
use serde::{Deserialize, Serialize}; | ||
|
||
use relay_general::protocol::{Addr, DebugId, NativeImagePath}; | ||
|
||
use crate::utils::deserialize_number_from_string; | ||
|
||
#[derive(Debug, Serialize, Deserialize, PartialEq, Clone)] | ||
#[serde(rename_all = "lowercase")] | ||
enum ImageType { | ||
MachO, | ||
Symbolic, | ||
} | ||
|
||
#[derive(Debug, Serialize, Deserialize, PartialEq, Clone)] | ||
pub struct NativeDebugImage { | ||
#[serde(alias = "name")] | ||
code_file: NativeImagePath, | ||
#[serde(alias = "id")] | ||
debug_id: DebugId, | ||
image_addr: Addr, | ||
|
||
#[serde(default)] | ||
image_vmaddr: Addr, | ||
|
||
#[serde(deserialize_with = "deserialize_number_from_string")] | ||
image_size: u64, | ||
|
||
#[serde(rename = "type")] | ||
image_type: ImageType, | ||
} | ||
|
||
#[cfg(test)] | ||
mod tests { | ||
use super::NativeDebugImage; | ||
|
||
use relay_general::protocol::{Addr, DebugImage, NativeDebugImage as RelayNativeDebugImage}; | ||
use relay_general::types::{Annotated, Map}; | ||
|
||
#[test] | ||
fn test_native_debug_image_compatibility() { | ||
let image_json = r#"{"debug_id":"32420279-25E2-34E6-8BC7-8A006A8F2425","image_addr":"0x000000010258c000","code_file":"/private/var/containers/Bundle/Application/C3511752-DD67-4FE8-9DA2-ACE18ADFAA61/TrendingMovies.app/TrendingMovies","type":"macho","image_size":1720320,"image_vmaddr":"0x0000000100000000"}"#; | ||
let image: NativeDebugImage = serde_json::from_str(image_json).unwrap(); | ||
let json = serde_json::to_string(&image).unwrap(); | ||
let annotated = Annotated::from_json(&json[..]).unwrap(); | ||
assert_eq!( | ||
Annotated::new(DebugImage::MachO(Box::new(RelayNativeDebugImage { | ||
arch: Annotated::empty(), | ||
code_file: Annotated::new("/private/var/containers/Bundle/Application/C3511752-DD67-4FE8-9DA2-ACE18ADFAA61/TrendingMovies.app/TrendingMovies".into()), | ||
code_id: Annotated::empty(), | ||
debug_file: Annotated::empty(), | ||
debug_id: Annotated::new("32420279-25E2-34E6-8BC7-8A006A8F2425".parse().unwrap()), | ||
image_addr: Annotated::new(Addr(4334338048)), | ||
image_size: Annotated::new(1720320), | ||
image_vmaddr: Annotated::new(Addr(4294967296)), | ||
other: Map::new(), | ||
}))), annotated); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would match on
v1
explicitly here. That would make the intent clearer, and if there's ever av2
, an old Relay instance would not try to expand it as a sample profile.