Skip to content

Commit 3064016

Browse files
feat(protocol) Add new mechanism fields to protocol to support exception groups (#2020)
1 parent 2a4d668 commit 3064016

File tree

3 files changed

+105
-5
lines changed

3 files changed

+105
-5
lines changed

CHANGELOG.md

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

33
## Unreleased
44

5-
**Internal**:
6-
7-
- Add BufferService with SQLite backend. ([#1920](https://github.com/getsentry/relay/pull/1920))
8-
- Adds iPad support for device.class synthesis in light normalization. ([#2008](https://github.com/getsentry/relay/pull/2008))
9-
105
**Breaking Changes**:
116

127
This release contains major changes to the web layer, including TCP and HTTP handling as well as all web endpoint handlers. Due to these changes, some functionality was retired and Relay responds differently in specific cases.
@@ -37,12 +32,15 @@ Metrics:
3732
- Don't sanitize transactions if no clustering rules exist and no UUIDs were scrubbed. ([#1976](https://github.com/getsentry/relay/pull/1976))
3833
- Add `thread.lock_mechanism` field to protocol. ([#1979](https://github.com/getsentry/relay/pull/1979))
3934
- Add `origin` to trace context and span. ([#1984](https://github.com/getsentry/relay/pull/1984))
35+
- Add new `mechanism` fields to protocol to support exception groups. ([#2020](https://github.com/getsentry/relay/pull/2020))
4036

4137
**Internal**:
4238

39+
- Add BufferService with SQLite backend. ([#1920](https://github.com/getsentry/relay/pull/1920))
4340
- Upgrade the web framework and related dependencies. ([#1938](https://github.com/getsentry/relay/pull/1938))
4441
- Apply transaction clustering rules before UUID scrubbing rules. ([#1964](https://github.com/getsentry/relay/pull/1964))
4542
- Use exposed device-class-synthesis feature flag to gate device.class synthesis in light normalization. ([#1974](https://github.com/getsentry/relay/pull/1974))
43+
- Adds iPad support for device.class synthesis in light normalization. ([#2008](https://github.com/getsentry/relay/pull/2008))
4644
- Pin schemars dependency to un-break schema docs generation. ([#2014](https://github.com/getsentry/relay/pull/2014))
4745

4846
## 23.3.1

relay-general/src/protocol/mechanism.rs

+66
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,48 @@ pub struct Mechanism {
144144
/// as the user explicitly captured the exception (and therefore kind of handled it)
145145
pub handled: Annotated<bool>,
146146

147+
/// An optional string value describing the source of the exception.
148+
///
149+
/// For chained exceptions, this should contain the platform-specific name of the property or
150+
/// attribute (on the parent exception) that this exception was acquired from. In the case of
151+
/// an array, it should include the zero-based array index as well.
152+
///
153+
/// - Python Examples: `"__context__"`, `"__cause__"`, `"exceptions[0]"`, `"exceptions[1]"`
154+
///
155+
/// - .NET Examples: `"InnerException"`, `"InnerExceptions[0]"`, `"InnerExceptions[1]"`
156+
///
157+
/// - JavaScript Examples: `"cause"`, `"errors[0]"`, `"errors[1]"`
158+
#[metastructure(
159+
required = "false",
160+
nonempty = "true",
161+
max_chars = "enumlike",
162+
deny_chars = " \t\r\n"
163+
)]
164+
pub source: Annotated<String>,
165+
166+
/// An optional boolean value, set `true` when the exception is the platform-specific exception
167+
/// group type. Defaults to `false`.
168+
///
169+
/// For example, exceptions of type `ExceptionGroup` (Python), `AggregateException` (.NET), and
170+
/// `AggregateError` (JavaScript) should have `"is_exception_group": true`. Other exceptions
171+
/// can omit this field.
172+
pub is_exception_group: Annotated<bool>,
173+
174+
/// An optional numeric value providing an ID for the exception relative to this specific event.
175+
/// It is referenced by the `parent_id` to reconstruct the logical tree of exceptions in an
176+
/// exception group.
177+
///
178+
/// This should contain an unsigned integer value starting with `0` for the last exception in
179+
/// the exception values list, then `1` for the previous exception, etc.
180+
pub exception_id: Annotated<u64>,
181+
182+
/// An optional numeric value pointing at the `exception_id` that is the direct parent of this
183+
/// exception, used to reconstruct the logical tree of exceptions in an exception group.
184+
///
185+
/// The last exception in the exception values list should omit this field, because it is the
186+
/// root exception and thus has no parent.
187+
pub parent_id: Annotated<u64>,
188+
147189
/// Arbitrary extra data that might help the user understand the error thrown by this mechanism.
148190
#[metastructure(pii = "true", bag_size = "medium")]
149191
#[metastructure(skip_serialization = "empty")]
@@ -168,6 +210,10 @@ impl FromValue for Mechanism {
168210
pub description: Annotated<String>,
169211
pub help_link: Annotated<String>,
170212
pub handled: Annotated<bool>,
213+
pub source: Annotated<String>,
214+
pub is_exception_group: Annotated<bool>,
215+
pub exception_id: Annotated<u64>,
216+
pub parent_id: Annotated<u64>,
171217
pub data: Annotated<Object<Value>>,
172218
pub meta: Annotated<MechanismMeta>,
173219
#[metastructure(additional_properties)]
@@ -210,6 +256,10 @@ impl FromValue for Mechanism {
210256
description: mechanism.description,
211257
help_link: mechanism.help_link,
212258
handled: mechanism.handled,
259+
source: mechanism.source,
260+
is_exception_group: mechanism.is_exception_group,
261+
exception_id: mechanism.exception_id,
262+
parent_id: mechanism.parent_id,
213263
data: mechanism.data,
214264
meta: mechanism.meta,
215265
other: mechanism.other,
@@ -222,6 +272,10 @@ impl FromValue for Mechanism {
222272
description: Annotated::empty(),
223273
help_link: Annotated::empty(),
224274
handled: Annotated::empty(),
275+
source: Annotated::empty(),
276+
is_exception_group: Annotated::empty(),
277+
exception_id: Annotated::empty(),
278+
parent_id: Annotated::empty(),
225279
data: Annotated::new(legacy.other),
226280
meta: Annotated::new(MechanismMeta {
227281
errno: Annotated::empty(),
@@ -270,6 +324,10 @@ mod tests {
270324
"description": "mydescription",
271325
"help_link": "https://developer.apple.com/library/content/qa/qa1367/_index.html",
272326
"handled": false,
327+
"source": "errors[0]",
328+
"is_exception_group": false,
329+
"exception_id": 1,
330+
"parent_id": 0,
273331
"data": {
274332
"relevant_address": "0x1"
275333
},
@@ -306,6 +364,10 @@ mod tests {
306364
"https://developer.apple.com/library/content/qa/qa1367/_index.html".to_string(),
307365
),
308366
handled: Annotated::new(false),
367+
source: Annotated::new("errors[0]".to_string()),
368+
is_exception_group: Annotated::new(false),
369+
exception_id: Annotated::new(1),
370+
parent_id: Annotated::new(0),
309371
data: {
310372
let mut map = Map::new();
311373
map.insert(
@@ -420,6 +482,10 @@ mod tests {
420482
description: Annotated::empty(),
421483
help_link: Annotated::empty(),
422484
handled: Annotated::empty(),
485+
source: Annotated::empty(),
486+
is_exception_group: Annotated::empty(),
487+
exception_id: Annotated::empty(),
488+
parent_id: Annotated::empty(),
423489
data: {
424490
let mut map = Map::new();
425491
map.insert(

relay-general/tests/snapshots/test_fixtures__event_schema.snap

+36
Original file line numberDiff line numberDiff line change
@@ -2209,6 +2209,16 @@ expression: "relay_general::protocol::event_json_schema()"
22092209
"null"
22102210
]
22112211
},
2212+
"exception_id": {
2213+
"description": " An optional numeric value providing an ID for the exception relative to this specific event.\n It is referenced by the `parent_id` to reconstruct the logical tree of exceptions in an\n exception group.\n\n This should contain an unsigned integer value starting with `0` for the last exception in\n the exception values list, then `1` for the previous exception, etc.",
2214+
"default": null,
2215+
"type": [
2216+
"integer",
2217+
"null"
2218+
],
2219+
"format": "uint64",
2220+
"minimum": 0.0
2221+
},
22122222
"handled": {
22132223
"description": " Flag indicating whether this exception was handled.\n\n This is a best-effort guess at whether the exception was handled by user code or not. For\n example:\n\n - Exceptions leading to a 500 Internal Server Error or to a hard process crash are\n `handled=false`, as the SDK typically has an integration that automatically captures the\n error.\n\n - Exceptions captured using `capture_exception` (called from user code) are `handled=true`\n as the user explicitly captured the exception (and therefore kind of handled it)",
22142224
"default": null,
@@ -2225,6 +2235,14 @@ expression: "relay_general::protocol::event_json_schema()"
22252235
"null"
22262236
]
22272237
},
2238+
"is_exception_group": {
2239+
"description": " An optional boolean value, set `true` when the exception is the platform-specific exception\n group type. Defaults to `false`.\n\n For example, exceptions of type `ExceptionGroup` (Python), `AggregateException` (.NET), and\n `AggregateError` (JavaScript) should have `\"is_exception_group\": true`. Other exceptions\n can omit this field.",
2240+
"default": null,
2241+
"type": [
2242+
"boolean",
2243+
"null"
2244+
]
2245+
},
22282246
"meta": {
22292247
"description": " Operating system or runtime meta information.",
22302248
"default": null,
@@ -2237,6 +2255,24 @@ expression: "relay_general::protocol::event_json_schema()"
22372255
}
22382256
]
22392257
},
2258+
"parent_id": {
2259+
"description": " An optional numeric value pointing at the `exception_id` that is the direct parent of this\n exception, used to reconstruct the logical tree of exceptions in an exception group.\n\n The last exception in the exception values list should omit this field, because it is the\n root exception and thus has no parent.",
2260+
"default": null,
2261+
"type": [
2262+
"integer",
2263+
"null"
2264+
],
2265+
"format": "uint64",
2266+
"minimum": 0.0
2267+
},
2268+
"source": {
2269+
"description": " An optional string value describing the source of the exception.\n\n For chained exceptions, this should contain the platform-specific name of the property or\n attribute (on the parent exception) that this exception was acquired from. In the case of\n an array, it should include the zero-based array index as well.\n\n - Python Examples: `\"__context__\"`, `\"__cause__\"`, `\"exceptions[0]\"`, `\"exceptions[1]\"`\n\n - .NET Examples: `\"InnerException\"`, `\"InnerExceptions[0]\"`, `\"InnerExceptions[1]\"`\n\n - JavaScript Examples: `\"cause\"`, `\"errors[0]\"`, `\"errors[1]\"`",
2270+
"default": null,
2271+
"type": [
2272+
"string",
2273+
"null"
2274+
]
2275+
},
22402276
"synthetic": {
22412277
"description": " If this is set then the exception is not a real exception but some\n form of synthetic error for instance from a signal handler, a hard\n segfault or similar where type and value are not useful for grouping\n or display purposes.",
22422278
"default": null,

0 commit comments

Comments
 (0)