Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(protocol): Add jvm debug file type #2002

Merged
merged 10 commits into from
Apr 17, 2023
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,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))
adinauer marked this conversation as resolved.
Show resolved Hide resolved

**Internal**:

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",
iker-barriocanal marked this conversation as resolved.
Show resolved Hide resolved
/// "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 = Object::new();
map.insert(
"other".to_string(),
Annotated::new(Value::String("value".to_string())),
);
map
iker-barriocanal marked this conversation as resolved.
Show resolved Hide resolved
},
})));

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 @@ -1015,6 +1015,9 @@ expression: "relay_general::protocol::event_json_schema()"
{
"$ref": "#/definitions/SourceMapDebugImage"
},
{
"$ref": "#/definitions/JvmDebugImage"
},
{
"type": "object",
"additionalProperties": true
Expand Down Expand Up @@ -2011,6 +2014,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