Skip to content

Commit

Permalink
feat(protocol): Add jvm debug file type (#2002)
Browse files Browse the repository at this point in the history
Co-authored-by: Iker Barriocanal <32816711+iker-barriocanal@users.noreply.github.com>
  • Loading branch information
adinauer and iker-barriocanal authored Apr 17, 2023
1 parent cd51343 commit 1769714
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ 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 `jvm` debug file type. ([#2002](https://github.com/getsentry/relay/pull/2002))
- Add new `mechanism` fields to protocol to support exception groups. ([#2020](https://github.com/getsentry/relay/pull/2020))
- Change `lock_reason` attribute to a `held_locks` dictionary in the `thread` interface. ([#2018](https://github.com/getsentry/relay/pull/2018))

Expand Down
47 changes: 47 additions & 0 deletions relay-general/src/protocol/debugmeta.rs
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,28 @@ pub struct SourceMapDebugImage {
pub other: Object<Value>,
}

/// A debug image consisting of source files for a JVM based language.
///
/// Examples:
///
/// ```json
/// {
/// "type": "jvm",
/// "debug_id": "395835f4-03e0-4436-80d3-136f0749a893"
/// }
/// ```
#[derive(Clone, Debug, Default, PartialEq, Empty, FromValue, IntoValue, ProcessValue)]
#[cfg_attr(feature = "jsonschema", derive(JsonSchema))]
pub struct JvmDebugImage {
/// Unique debug identifier of the bundle.
#[metastructure(required = "true")]
pub debug_id: Annotated<DebugId>,

/// Additional arbitrary fields for forwards compatibility.
#[metastructure(additional_properties)]
pub other: Object<Value>,
}

/// Proguard mapping file.
///
/// Proguard images refer to `mapping.txt` files generated when Proguard obfuscates function names. The Java SDK integrations assign this file a unique identifier, which has to be included in the list of images.
Expand Down Expand Up @@ -486,6 +508,8 @@ pub enum DebugImage {
Wasm(Box<NativeDebugImage>),
/// Source map debug image.
SourceMap(Box<SourceMapDebugImage>),
/// JVM based debug image.
Jvm(Box<JvmDebugImage>),
/// A debug image that is unknown to this protocol specification.
#[metastructure(fallback_variant)]
Other(Object<Value>),
Expand Down Expand Up @@ -559,6 +583,29 @@ mod tests {
assert_eq!(json, image.to_json_pretty().unwrap());
}

#[test]
fn test_debug_image_jvm_based_roundtrip() {
let json = r#"{
"debug_id": "395835f4-03e0-4436-80d3-136f0749a893",
"other": "value",
"type": "jvm"
}"#;
let image = Annotated::new(DebugImage::Jvm(Box::new(JvmDebugImage {
debug_id: Annotated::new("395835f4-03e0-4436-80d3-136f0749a893".parse().unwrap()),
other: {
let mut map = Map::new();
map.insert(
"other".to_string(),
Annotated::new(Value::String("value".to_string())),
);
map
},
})));

assert_eq!(image, Annotated::from_json(json).unwrap());
assert_eq!(json, image.to_json_pretty().unwrap());
}

#[test]
fn test_debug_image_apple_roundtrip() {
let json = r#"{
Expand Down
6 changes: 6 additions & 0 deletions relay-general/src/protocol/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,12 @@ pub struct Metrics {
#[metastructure(field = "ms.processing.proguard")]
pub ms_processing_proguard: Annotated<u64>,

/// The number of milliseconds Sentry spent resolving sources for a java event.
///
/// This metric is measured in Sentry and reported in the java processing task.
#[metastructure(field = "ms.processing.jvm")]
pub ms_processing_jvm: Annotated<u64>,

/// The number of milliseconds sentry spent resolving minified stack traces for a javascript event.
///
/// This metric is measured in Sentry and reported in the javascript processing task.
Expand Down
28 changes: 28 additions & 0 deletions relay-general/tests/snapshots/test_fixtures__event_schema.snap
Original file line number Diff line number Diff line change
Expand Up @@ -1018,6 +1018,9 @@ expression: "relay_general::protocol::event_json_schema()"
{
"$ref": "#/definitions/SourceMapDebugImage"
},
{
"$ref": "#/definitions/JvmDebugImage"
},
{
"type": "object",
"additionalProperties": true
Expand Down Expand Up @@ -2014,6 +2017,31 @@ expression: "relay_general::protocol::event_json_schema()"
}
]
},
"JvmDebugImage": {
"description": " A debug image consisting of source files for a JVM based language.\n\n Examples:\n\n ```json\n {\n \"type\": \"jvm\",\n \"debug_id\": \"395835f4-03e0-4436-80d3-136f0749a893\"\n }\n ```",
"anyOf": [
{
"type": "object",
"required": [
"debug_id"
],
"properties": {
"debug_id": {
"description": " Unique debug identifier of the bundle.",
"anyOf": [
{
"$ref": "#/definitions/DebugId"
},
{
"type": "null"
}
]
}
},
"additionalProperties": false
}
]
},
"Level": {
"description": "Severity level of an event or breadcrumb.",
"type": "string",
Expand Down

0 comments on commit 1769714

Please sign in to comment.