Skip to content

Commit c3a0efd

Browse files
fix(protocol): Flatten Linux distribution fields into os.context (#4292)
(continuation of #3443 ) <!-- Describe your PR here. --> To make these fields searchable, we had to change from a nested to a flattened approach. This is provided in sentry-native ([relevant PR](getsentry/sentry-native#963)). The update is also tracked on the docs side: getsentry/sentry-docs#11936
1 parent 6306552 commit c3a0efd

File tree

5 files changed

+51
-83
lines changed

5 files changed

+51
-83
lines changed

Diff for: CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
## 24.11.1
44

5+
**Breaking Changes**:
6+
- Flatten Linux distribution fields into `os.context`([#4292](https://github.com/getsentry/relay/pull/4292))
7+
58
**Bug Fixes**:
69

710
- Terminate the process when one of the services crashes. ([#4249](https://github.com/getsentry/relay/pull/4249))

Diff for: py/CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Changelog
22

3+
## Unreleased
4+
5+
**Breaking Changes**:
6+
- Flatten Linux distribution fields into `os.context`([#4292](https://github.com/getsentry/relay/pull/4292))
7+
38
## 0.9.3
49

510
- Add computed contexts for `os`, `browser` and `runtime` during normalization. ([#4239](https://github.com/getsentry/relay/pull/4239))

Diff for: relay-event-normalization/src/normalize/user_agent.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -962,7 +962,9 @@ mod tests {
962962
build: ~,
963963
kernel_version: ~,
964964
rooted: ~,
965-
distribution: ~,
965+
distribution_name: ~,
966+
distribution_version: ~,
967+
distribution_pretty_name: ~,
966968
raw_description: ~,
967969
other: {},
968970
}
@@ -1035,7 +1037,9 @@ mod tests {
10351037
build: ~,
10361038
kernel_version: ~,
10371039
rooted: ~,
1038-
distribution: ~,
1040+
distribution_name: ~,
1041+
distribution_version: ~,
1042+
distribution_pretty_name: ~,
10391043
raw_description: ~,
10401044
other: {},
10411045
}

Diff for: relay-event-schema/src/protocol/contexts/os.rs

+16-37
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,12 @@ pub struct OsContext {
3232
pub rooted: Annotated<bool>,
3333

3434
/// Meta-data for the Linux Distribution.
35-
#[metastructure(skip_serialization = "empty")]
36-
pub distribution: Annotated<LinuxDistribution>,
35+
#[metastructure(pii = "maybe")]
36+
pub distribution_name: Annotated<String>,
37+
#[metastructure(pii = "maybe")]
38+
pub distribution_version: Annotated<String>,
39+
#[metastructure(pii = "maybe")]
40+
pub distribution_pretty_name: Annotated<String>,
3741

3842
/// Unprocessed operating system info.
3943
///
@@ -48,28 +52,6 @@ pub struct OsContext {
4852
pub other: Object<Value>,
4953
}
5054

51-
/// Metadata for the Linux Distribution.
52-
#[derive(Clone, Debug, Default, PartialEq, Empty, FromValue, IntoValue, ProcessValue)]
53-
pub struct LinuxDistribution {
54-
/// An index-able name that is stable for each distribution.
55-
pub name: Annotated<String>,
56-
/// The version of the distribution (missing in distributions with solely rolling release).
57-
#[metastructure(skip_serialization = "empty")]
58-
pub version: Annotated<String>,
59-
/// A full rendering of name + version + release name (not available in all distributions).
60-
#[metastructure(skip_serialization = "empty")]
61-
pub pretty_name: Annotated<String>,
62-
63-
/// Additional arbitrary fields for forwards compatibility.
64-
#[metastructure(
65-
additional_properties,
66-
retain = "true",
67-
pii = "maybe",
68-
skip_serialization = "empty"
69-
)]
70-
pub other: Object<Value>,
71-
}
72-
7355
impl super::DefaultContext for OsContext {
7456
fn default_key() -> &'static str {
7557
"os"
@@ -127,7 +109,9 @@ mod tests {
127109
kernel_version: Annotated::new("17.4.0".to_string()),
128110
rooted: Annotated::new(true),
129111
raw_description: Annotated::new("iOS 11.4.2 FEEDFACE (17.4.0)".to_string()),
130-
distribution: Annotated::empty(),
112+
distribution_name: Annotated::empty(),
113+
distribution_version: Annotated::empty(),
114+
distribution_pretty_name: Annotated::empty(),
131115
other: {
132116
let mut map = Object::new();
133117
map.insert(
@@ -144,16 +128,14 @@ mod tests {
144128

145129
#[test]
146130
fn test_os_context_linux_roundtrip() {
147-
let json = r#"{
131+
let json: &str = r#"{
148132
"os": "Linux 5.15.133",
149133
"name": "Linux",
150134
"version": "5.15.133",
151135
"build": "1-microsoft-standard-WSL2",
152-
"distribution": {
153-
"name": "ubuntu",
154-
"version": "22.04",
155-
"pretty_name": "Ubuntu 22.04.4 LTS"
156-
},
136+
"distribution_name": "ubuntu",
137+
"distribution_version": "22.04",
138+
"distribution_pretty_name": "Ubuntu 22.04.4 LTS",
157139
"type": "os"
158140
}"#;
159141
let context = Annotated::new(Context::Os(Box::new(OsContext {
@@ -164,12 +146,9 @@ mod tests {
164146
kernel_version: Annotated::empty(),
165147
rooted: Annotated::empty(),
166148
raw_description: Annotated::empty(),
167-
distribution: Annotated::new(LinuxDistribution {
168-
name: Annotated::new("ubuntu".to_string()),
169-
version: Annotated::new("22.04".to_string()),
170-
pretty_name: Annotated::new("Ubuntu 22.04.4 LTS".to_string()),
171-
other: Object::default(),
172-
}),
149+
distribution_name: Annotated::new("ubuntu".to_string()),
150+
distribution_version: Annotated::new("22.04".to_string()),
151+
distribution_pretty_name: Annotated::new("Ubuntu 22.04.4 LTS".to_string()),
173152
other: Object::default(),
174153
})));
175154

Diff for: relay-server/tests/snapshots/test_fixtures__event_schema.snap

+21-44
Original file line numberDiff line numberDiff line change
@@ -2149,41 +2149,6 @@ expression: "relay_event_schema::protocol::event_json_schema()"
21492149
"fatal"
21502150
]
21512151
},
2152-
"LinuxDistribution": {
2153-
"description": " Metadata for the Linux Distribution.",
2154-
"anyOf": [
2155-
{
2156-
"type": "object",
2157-
"properties": {
2158-
"name": {
2159-
"description": " An index-able name that is stable for each distribution.",
2160-
"default": null,
2161-
"type": [
2162-
"string",
2163-
"null"
2164-
]
2165-
},
2166-
"pretty_name": {
2167-
"description": " A full rendering of name + version + release name (not available in all distributions).",
2168-
"default": null,
2169-
"type": [
2170-
"string",
2171-
"null"
2172-
]
2173-
},
2174-
"version": {
2175-
"description": " The version of the distribution (missing in distributions with solely rolling release).",
2176-
"default": null,
2177-
"type": [
2178-
"string",
2179-
"null"
2180-
]
2181-
}
2182-
},
2183-
"additionalProperties": false
2184-
}
2185-
]
2186-
},
21872152
"LockReason": {
21882153
"description": " Represents an instance of a held lock (java monitor object) in a thread.",
21892154
"anyOf": [
@@ -2770,16 +2735,28 @@ expression: "relay_event_schema::protocol::event_json_schema()"
27702735
"null"
27712736
]
27722737
},
2773-
"distribution": {
2774-
"description": " Meta-data for the Linux Distribution.",
2738+
"distribution_name": {
2739+
"description": " An index-able name that is stable for each distribution.",
27752740
"default": null,
2776-
"anyOf": [
2777-
{
2778-
"$ref": "#/definitions/LinuxDistribution"
2779-
},
2780-
{
2781-
"type": "null"
2782-
}
2741+
"type": [
2742+
"string",
2743+
"null"
2744+
]
2745+
},
2746+
"distribution_version": {
2747+
"description": " The version of the distribution (missing in distributions with solely rolling release).",
2748+
"default": null,
2749+
"type": [
2750+
"string",
2751+
"null"
2752+
]
2753+
},
2754+
"distribution_pretty_name": {
2755+
"description": " A full rendering of name + version + release name (not available in all distributions).",
2756+
"default": null,
2757+
"type": [
2758+
"string",
2759+
"null"
27832760
]
27842761
},
27852762
"kernel_version": {

0 commit comments

Comments
 (0)