Skip to content

Commit ff8697f

Browse files
committed
suggestions
1 parent 9c7ebde commit ff8697f

File tree

3 files changed

+12
-20
lines changed

3 files changed

+12
-20
lines changed

py/tests/test_processing.py

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -119,18 +119,16 @@ def test_normalize_user_agent(must_normalize):
119119
)
120120

121121
if must_normalize:
122-
assert event["contexts"]["browser"] == {
123-
"browser": "Firefox 15.0.1",
124-
"name": "Firefox",
125-
"version": "15.0.1",
126-
"type": "browser",
127-
}
128-
assert event["contexts"]["client_os"] == {
129-
"name": "Ubuntu",
130-
"os": "Ubuntu",
131-
"type": "os",
122+
assert event["contexts"] == {
123+
"browser": {
124+
"browser": "Firefox 15.0.1",
125+
"name": "Firefox",
126+
"version": "15.0.1",
127+
"type": "browser",
128+
},
129+
"client_os": {"name": "Ubuntu", "os": "Ubuntu", "type": "os"},
130+
"trace": pytest.mock.ANY,
132131
}
133-
assert set(event["contexts"].keys()) == {"browser", "client_os", "trace"}
134132
else:
135133
assert set(event["contexts"].keys()) == {"trace"}
136134

relay-event-schema/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ debugid = { workspace = true, features = ["serde"] }
2020
enumset = { workspace = true }
2121
minidump = { workspace = true }
2222
opentelemetry-proto = { workspace = true, features = ["gen-tonic", "trace"] }
23+
rand = { workspace = true }
2324
relay-common = { workspace = true }
2425
relay-conventions = { workspace = true }
2526
relay-base-schema = { workspace = true }
@@ -31,7 +32,6 @@ serde_json = { workspace = true }
3132
thiserror = { workspace = true }
3233
url = { workspace = true }
3334
uuid = { workspace = true }
34-
rand.workspace = true
3535

3636
[dev-dependencies]
3737
insta = { workspace = true }

relay-event-schema/src/protocol/contexts/trace.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -171,14 +171,8 @@ relay_common::impl_str_serde!(SpanId, "a span identifier");
171171

172172
impl SpanId {
173173
pub fn random() -> Self {
174-
let mut span_bytes = [0u8; 8];
175-
rand::rng().fill_bytes(&mut span_bytes);
176-
177-
if !span_bytes.iter().all(|&x| x == 0) {
178-
Self(span_bytes)
179-
} else {
180-
Self([42u8; 8])
181-
}
174+
let value: u64 = rand::random_range(1..=u64::MAX);
175+
Self(value.to_ne_bytes())
182176
}
183177
}
184178

0 commit comments

Comments
 (0)