Skip to content

Commit

Permalink
feat(protocol) Add new mechanism fields to protocol to support exce…
Browse files Browse the repository at this point in the history
…ption groups (#2020)
  • Loading branch information
mattjohnsonpint committed Apr 12, 2023
1 parent 2a4d668 commit 3064016
Show file tree
Hide file tree
Showing 3 changed files with 105 additions and 5 deletions.
8 changes: 3 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,6 @@

## Unreleased

**Internal**:

- Add BufferService with SQLite backend. ([#1920](https://github.com/getsentry/relay/pull/1920))
- Adds iPad support for device.class synthesis in light normalization. ([#2008](https://github.com/getsentry/relay/pull/2008))

**Breaking Changes**:

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.
Expand Down Expand Up @@ -37,12 +32,15 @@ Metrics:
- Don't sanitize transactions if no clustering rules exist and no UUIDs were scrubbed. ([#1976](https://github.com/getsentry/relay/pull/1976))
- Add `thread.lock_mechanism` field to protocol. ([#1979](https://github.com/getsentry/relay/pull/1979))
- Add `origin` to trace context and span. ([#1984](https://github.com/getsentry/relay/pull/1984))
- Add new `mechanism` fields to protocol to support exception groups. ([#2020](https://github.com/getsentry/relay/pull/2020))

**Internal**:

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

## 23.3.1
Expand Down
66 changes: 66 additions & 0 deletions relay-general/src/protocol/mechanism.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,48 @@ pub struct Mechanism {
/// as the user explicitly captured the exception (and therefore kind of handled it)
pub handled: Annotated<bool>,

/// An optional string value describing the source of the exception.
///
/// For chained exceptions, this should contain the platform-specific name of the property or
/// attribute (on the parent exception) that this exception was acquired from. In the case of
/// an array, it should include the zero-based array index as well.
///
/// - Python Examples: `"__context__"`, `"__cause__"`, `"exceptions[0]"`, `"exceptions[1]"`
///
/// - .NET Examples: `"InnerException"`, `"InnerExceptions[0]"`, `"InnerExceptions[1]"`
///
/// - JavaScript Examples: `"cause"`, `"errors[0]"`, `"errors[1]"`
#[metastructure(
required = "false",
nonempty = "true",
max_chars = "enumlike",
deny_chars = " \t\r\n"
)]
pub source: Annotated<String>,

/// An optional boolean value, set `true` when the exception is the platform-specific exception
/// group type. Defaults to `false`.
///
/// For example, exceptions of type `ExceptionGroup` (Python), `AggregateException` (.NET), and
/// `AggregateError` (JavaScript) should have `"is_exception_group": true`. Other exceptions
/// can omit this field.
pub is_exception_group: Annotated<bool>,

/// An optional numeric value providing an ID for the exception relative to this specific event.
/// It is referenced by the `parent_id` to reconstruct the logical tree of exceptions in an
/// exception group.
///
/// This should contain an unsigned integer value starting with `0` for the last exception in
/// the exception values list, then `1` for the previous exception, etc.
pub exception_id: Annotated<u64>,

/// An optional numeric value pointing at the `exception_id` that is the direct parent of this
/// exception, used to reconstruct the logical tree of exceptions in an exception group.
///
/// The last exception in the exception values list should omit this field, because it is the
/// root exception and thus has no parent.
pub parent_id: Annotated<u64>,

/// Arbitrary extra data that might help the user understand the error thrown by this mechanism.
#[metastructure(pii = "true", bag_size = "medium")]
#[metastructure(skip_serialization = "empty")]
Expand All @@ -168,6 +210,10 @@ impl FromValue for Mechanism {
pub description: Annotated<String>,
pub help_link: Annotated<String>,
pub handled: Annotated<bool>,
pub source: Annotated<String>,
pub is_exception_group: Annotated<bool>,
pub exception_id: Annotated<u64>,
pub parent_id: Annotated<u64>,
pub data: Annotated<Object<Value>>,
pub meta: Annotated<MechanismMeta>,
#[metastructure(additional_properties)]
Expand Down Expand Up @@ -210,6 +256,10 @@ impl FromValue for Mechanism {
description: mechanism.description,
help_link: mechanism.help_link,
handled: mechanism.handled,
source: mechanism.source,
is_exception_group: mechanism.is_exception_group,
exception_id: mechanism.exception_id,
parent_id: mechanism.parent_id,
data: mechanism.data,
meta: mechanism.meta,
other: mechanism.other,
Expand All @@ -222,6 +272,10 @@ impl FromValue for Mechanism {
description: Annotated::empty(),
help_link: Annotated::empty(),
handled: Annotated::empty(),
source: Annotated::empty(),
is_exception_group: Annotated::empty(),
exception_id: Annotated::empty(),
parent_id: Annotated::empty(),
data: Annotated::new(legacy.other),
meta: Annotated::new(MechanismMeta {
errno: Annotated::empty(),
Expand Down Expand Up @@ -270,6 +324,10 @@ mod tests {
"description": "mydescription",
"help_link": "https://developer.apple.com/library/content/qa/qa1367/_index.html",
"handled": false,
"source": "errors[0]",
"is_exception_group": false,
"exception_id": 1,
"parent_id": 0,
"data": {
"relevant_address": "0x1"
},
Expand Down Expand Up @@ -306,6 +364,10 @@ mod tests {
"https://developer.apple.com/library/content/qa/qa1367/_index.html".to_string(),
),
handled: Annotated::new(false),
source: Annotated::new("errors[0]".to_string()),
is_exception_group: Annotated::new(false),
exception_id: Annotated::new(1),
parent_id: Annotated::new(0),
data: {
let mut map = Map::new();
map.insert(
Expand Down Expand Up @@ -420,6 +482,10 @@ mod tests {
description: Annotated::empty(),
help_link: Annotated::empty(),
handled: Annotated::empty(),
source: Annotated::empty(),
is_exception_group: Annotated::empty(),
exception_id: Annotated::empty(),
parent_id: Annotated::empty(),
data: {
let mut map = Map::new();
map.insert(
Expand Down
36 changes: 36 additions & 0 deletions relay-general/tests/snapshots/test_fixtures__event_schema.snap
Original file line number Diff line number Diff line change
Expand Up @@ -2209,6 +2209,16 @@ expression: "relay_general::protocol::event_json_schema()"
"null"
]
},
"exception_id": {
"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.",
"default": null,
"type": [
"integer",
"null"
],
"format": "uint64",
"minimum": 0.0
},
"handled": {
"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)",
"default": null,
Expand All @@ -2225,6 +2235,14 @@ expression: "relay_general::protocol::event_json_schema()"
"null"
]
},
"is_exception_group": {
"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.",
"default": null,
"type": [
"boolean",
"null"
]
},
"meta": {
"description": " Operating system or runtime meta information.",
"default": null,
Expand All @@ -2237,6 +2255,24 @@ expression: "relay_general::protocol::event_json_schema()"
}
]
},
"parent_id": {
"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.",
"default": null,
"type": [
"integer",
"null"
],
"format": "uint64",
"minimum": 0.0
},
"source": {
"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]\"`",
"default": null,
"type": [
"string",
"null"
]
},
"synthetic": {
"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.",
"default": null,
Expand Down

0 comments on commit 3064016

Please sign in to comment.