diff --git a/CHANGELOG.md b/CHANGELOG.md index 7b5a363512..aab17644cd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,9 +2,10 @@ ## Unreleased -**Features:** +**Features**: - Add inbound filters for Annotated types. ([#3420](https://github.com/getsentry/relay/pull/3420)) +- Add Linux distributions to os context. ([#3443](https://github.com/getsentry/relay/pull/3443)) **Internal:** diff --git a/relay-event-normalization/src/normalize/user_agent.rs b/relay-event-normalization/src/normalize/user_agent.rs index f51b526be4..ea2ab9e105 100644 --- a/relay-event-normalization/src/normalize/user_agent.rs +++ b/relay-event-normalization/src/normalize/user_agent.rs @@ -957,6 +957,7 @@ OsContext { build: ~, kernel_version: ~, rooted: ~, + distribution: ~, raw_description: ~, other: {}, } @@ -1028,6 +1029,7 @@ OsContext { build: ~, kernel_version: ~, rooted: ~, + distribution: ~, raw_description: ~, other: {}, } diff --git a/relay-event-schema/src/protocol/contexts/os.rs b/relay-event-schema/src/protocol/contexts/os.rs index 340dbef8ea..5f1ccecf35 100644 --- a/relay-event-schema/src/protocol/contexts/os.rs +++ b/relay-event-schema/src/protocol/contexts/os.rs @@ -31,6 +31,10 @@ pub struct OsContext { /// Indicator if the OS is rooted (mobile mostly). pub rooted: Annotated, + /// Meta-data for the Linux Distribution. + #[metastructure(skip_serialization = "empty")] + pub distribution: Annotated, + /// Unprocessed operating system info. /// /// An unprocessed description string obtained by the operating system. For some well-known @@ -44,6 +48,29 @@ pub struct OsContext { pub other: Object, } +/// Metadata for the Linux Distribution. +#[derive(Clone, Debug, Default, PartialEq, Empty, FromValue, IntoValue, ProcessValue)] +#[cfg_attr(feature = "jsonschema", derive(JsonSchema))] +pub struct LinuxDistribution { + /// An index-able name that is stable for each distribution. + pub name: Annotated, + /// The version of the distribution (missing in distributions with solely rolling release). + #[metastructure(skip_serialization = "empty")] + pub version: Annotated, + /// A full rendering of name + version + release name (not available in all distributions). + #[metastructure(skip_serialization = "empty")] + pub pretty_name: Annotated, + + /// Additional arbitrary fields for forwards compatibility. + #[metastructure( + additional_properties, + retain = "true", + pii = "maybe", + skip_serialization = "empty" + )] + pub other: Object, +} + impl super::DefaultContext for OsContext { fn default_key() -> &'static str { "os" @@ -99,6 +126,7 @@ 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(), other: { let mut map = Object::new(); map.insert( @@ -112,4 +140,37 @@ mod tests { assert_eq!(context, Annotated::from_json(json).unwrap()); assert_eq!(json, context.to_json_pretty().unwrap()); } + + #[test] + fn test_os_context_linux_roundtrip() { + let json = r#"{ + "name": "Linux", + "version": "5.15.133", + "build": "1-microsoft-standard-WSL2", + "distribution": { + "name": "ubuntu", + "version": "22.04", + "pretty_name": "Ubuntu 22.04.4 LTS" + }, + "type": "os" +}"#; + let context = Annotated::new(Context::Os(Box::new(OsContext { + name: Annotated::new("Linux".to_string()), + version: Annotated::new("5.15.133".to_string()), + build: Annotated::new(LenientString("1-microsoft-standard-WSL2".to_string())), + 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(), + }), + other: Object::default(), + }))); + + assert_eq!(context, Annotated::from_json(json).unwrap()); + assert_eq!(json, context.to_json_pretty().unwrap()); + } } diff --git a/relay-server/tests/snapshots/test_fixtures__event_schema.snap b/relay-server/tests/snapshots/test_fixtures__event_schema.snap index f957194865..d9e8edbcf9 100644 --- a/relay-server/tests/snapshots/test_fixtures__event_schema.snap +++ b/relay-server/tests/snapshots/test_fixtures__event_schema.snap @@ -2170,6 +2170,41 @@ 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": [ @@ -2756,6 +2791,18 @@ expression: "relay_event_schema::protocol::event_json_schema()" "null" ] }, + "distribution": { + "description": " Meta-data for the Linux Distribution.", + "default": null, + "anyOf": [ + { + "$ref": "#/definitions/LinuxDistribution" + }, + { + "type": "null" + } + ] + }, "kernel_version": { "description": " Current kernel version.\n\n This is typically the entire output of the `uname` syscall.", "default": null,