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

fix(protocol): Flatten Linux distribution fields into os.context #4292

Merged
merged 2 commits into from
Nov 28, 2024
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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

## Unreleased

**Breaking Changes**:
- Flatten Linux distribution fields into `os.context`([#4292](https://github.com/getsentry/relay/pull/4292))

**Bug Fixes**:

- Terminate the process when one of the services crashes. ([#4249](https://github.com/getsentry/relay/pull/4249))
Expand Down
5 changes: 5 additions & 0 deletions py/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## Unreleased

**Breaking Changes**:
- Flatten Linux distribution fields into `os.context`([#4292](https://github.com/getsentry/relay/pull/4292))

## 0.9.3

- Add computed contexts for `os`, `browser` and `runtime` during normalization. ([#4239](https://github.com/getsentry/relay/pull/4239))
Expand Down
8 changes: 6 additions & 2 deletions relay-event-normalization/src/normalize/user_agent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -962,7 +962,9 @@ mod tests {
build: ~,
kernel_version: ~,
rooted: ~,
distribution: ~,
distribution_name: ~,
distribution_version: ~,
distribution_pretty_name: ~,
raw_description: ~,
other: {},
}
Expand Down Expand Up @@ -1035,7 +1037,9 @@ mod tests {
build: ~,
kernel_version: ~,
rooted: ~,
distribution: ~,
distribution_name: ~,
distribution_version: ~,
distribution_pretty_name: ~,
raw_description: ~,
other: {},
}
Expand Down
53 changes: 16 additions & 37 deletions relay-event-schema/src/protocol/contexts/os.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,12 @@ pub struct OsContext {
pub rooted: Annotated<bool>,

/// Meta-data for the Linux Distribution.
#[metastructure(skip_serialization = "empty")]
pub distribution: Annotated<LinuxDistribution>,
#[metastructure(pii = "maybe")]
pub distribution_name: Annotated<String>,
#[metastructure(pii = "maybe")]
pub distribution_version: Annotated<String>,
#[metastructure(pii = "maybe")]
pub distribution_pretty_name: Annotated<String>,

/// Unprocessed operating system info.
///
Expand All @@ -48,28 +52,6 @@ pub struct OsContext {
pub other: Object<Value>,
}

/// Metadata for the Linux Distribution.
#[derive(Clone, Debug, Default, PartialEq, Empty, FromValue, IntoValue, ProcessValue)]
pub struct LinuxDistribution {
/// An index-able name that is stable for each distribution.
pub name: Annotated<String>,
/// The version of the distribution (missing in distributions with solely rolling release).
#[metastructure(skip_serialization = "empty")]
pub version: Annotated<String>,
/// A full rendering of name + version + release name (not available in all distributions).
#[metastructure(skip_serialization = "empty")]
pub pretty_name: Annotated<String>,

/// Additional arbitrary fields for forwards compatibility.
#[metastructure(
additional_properties,
retain = "true",
pii = "maybe",
skip_serialization = "empty"
)]
pub other: Object<Value>,
}

impl super::DefaultContext for OsContext {
fn default_key() -> &'static str {
"os"
Expand Down Expand Up @@ -127,7 +109,9 @@ mod tests {
kernel_version: Annotated::new("17.4.0".to_string()),
rooted: Annotated::new(true),
raw_description: Annotated::new("iOS 11.4.2 FEEDFACE (17.4.0)".to_string()),
distribution: Annotated::empty(),
distribution_name: Annotated::empty(),
distribution_version: Annotated::empty(),
distribution_pretty_name: Annotated::empty(),
other: {
let mut map = Object::new();
map.insert(
Expand All @@ -144,16 +128,14 @@ mod tests {

#[test]
fn test_os_context_linux_roundtrip() {
let json = r#"{
let json: &str = r#"{
"os": "Linux 5.15.133",
"name": "Linux",
"version": "5.15.133",
"build": "1-microsoft-standard-WSL2",
"distribution": {
"name": "ubuntu",
"version": "22.04",
"pretty_name": "Ubuntu 22.04.4 LTS"
},
"distribution_name": "ubuntu",
"distribution_version": "22.04",
"distribution_pretty_name": "Ubuntu 22.04.4 LTS",
"type": "os"
}"#;
let context = Annotated::new(Context::Os(Box::new(OsContext {
Expand All @@ -164,12 +146,9 @@ mod tests {
kernel_version: Annotated::empty(),
rooted: Annotated::empty(),
raw_description: Annotated::empty(),
distribution: Annotated::new(LinuxDistribution {
name: Annotated::new("ubuntu".to_string()),
version: Annotated::new("22.04".to_string()),
pretty_name: Annotated::new("Ubuntu 22.04.4 LTS".to_string()),
other: Object::default(),
}),
distribution_name: Annotated::new("ubuntu".to_string()),
distribution_version: Annotated::new("22.04".to_string()),
distribution_pretty_name: Annotated::new("Ubuntu 22.04.4 LTS".to_string()),
other: Object::default(),
})));

Expand Down
65 changes: 21 additions & 44 deletions relay-server/tests/snapshots/test_fixtures__event_schema.snap
Original file line number Diff line number Diff line change
Expand Up @@ -2149,41 +2149,6 @@ expression: "relay_event_schema::protocol::event_json_schema()"
"fatal"
]
},
"LinuxDistribution": {
"description": " Metadata for the Linux Distribution.",
"anyOf": [
{
"type": "object",
"properties": {
"name": {
"description": " An index-able name that is stable for each distribution.",
"default": null,
"type": [
"string",
"null"
]
},
"pretty_name": {
"description": " A full rendering of name + version + release name (not available in all distributions).",
"default": null,
"type": [
"string",
"null"
]
},
"version": {
"description": " The version of the distribution (missing in distributions with solely rolling release).",
"default": null,
"type": [
"string",
"null"
]
}
},
"additionalProperties": false
}
]
},
"LockReason": {
"description": " Represents an instance of a held lock (java monitor object) in a thread.",
"anyOf": [
Expand Down Expand Up @@ -2770,16 +2735,28 @@ expression: "relay_event_schema::protocol::event_json_schema()"
"null"
]
},
"distribution": {
"description": " Meta-data for the Linux Distribution.",
"distribution_name": {
"description": " An index-able name that is stable for each distribution.",
"default": null,
"anyOf": [
{
"$ref": "#/definitions/LinuxDistribution"
},
{
"type": "null"
}
"type": [
"string",
"null"
]
},
"distribution_version": {
"description": " The version of the distribution (missing in distributions with solely rolling release).",
"default": null,
"type": [
"string",
"null"
]
},
"distribution_pretty_name": {
"description": " A full rendering of name + version + release name (not available in all distributions).",
"default": null,
"type": [
"string",
"null"
]
},
"kernel_version": {
Expand Down