From 1769714cee44c14b2e812cb79d02e43d83efc782 Mon Sep 17 00:00:00 2001 From: Alexander Dinauer Date: Mon, 17 Apr 2023 08:46:08 +0200 Subject: [PATCH] feat(protocol): Add `jvm` debug file type (#2002) Co-authored-by: Iker Barriocanal <32816711+iker-barriocanal@users.noreply.github.com> --- CHANGELOG.md | 1 + relay-general/src/protocol/debugmeta.rs | 47 +++++++++++++++++++ relay-general/src/protocol/metrics.rs | 6 +++ .../test_fixtures__event_schema.snap | 28 +++++++++++ 4 files changed, 82 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2394b0d160..87abe9bb8a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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)) diff --git a/relay-general/src/protocol/debugmeta.rs b/relay-general/src/protocol/debugmeta.rs index 29dae8f2cb..7c91363509 100644 --- a/relay-general/src/protocol/debugmeta.rs +++ b/relay-general/src/protocol/debugmeta.rs @@ -447,6 +447,28 @@ pub struct SourceMapDebugImage { pub other: Object, } +/// 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, + + /// Additional arbitrary fields for forwards compatibility. + #[metastructure(additional_properties)] + pub other: Object, +} + /// 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. @@ -486,6 +508,8 @@ pub enum DebugImage { Wasm(Box), /// Source map debug image. SourceMap(Box), + /// JVM based debug image. + Jvm(Box), /// A debug image that is unknown to this protocol specification. #[metastructure(fallback_variant)] Other(Object), @@ -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#"{ diff --git a/relay-general/src/protocol/metrics.rs b/relay-general/src/protocol/metrics.rs index 9492808af3..bab36722da 100644 --- a/relay-general/src/protocol/metrics.rs +++ b/relay-general/src/protocol/metrics.rs @@ -128,6 +128,12 @@ pub struct Metrics { #[metastructure(field = "ms.processing.proguard")] pub ms_processing_proguard: Annotated, + /// 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, + /// 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. diff --git a/relay-general/tests/snapshots/test_fixtures__event_schema.snap b/relay-general/tests/snapshots/test_fixtures__event_schema.snap index f253ddf3df..9fc7b2a314 100644 --- a/relay-general/tests/snapshots/test_fixtures__event_schema.snap +++ b/relay-general/tests/snapshots/test_fixtures__event_schema.snap @@ -1018,6 +1018,9 @@ expression: "relay_general::protocol::event_json_schema()" { "$ref": "#/definitions/SourceMapDebugImage" }, + { + "$ref": "#/definitions/JvmDebugImage" + }, { "type": "object", "additionalProperties": true @@ -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",