From f8841223ee689ff0ce50a9bd9d75223a4fb4ddd0 Mon Sep 17 00:00:00 2001 From: Stefan Jandl Date: Mon, 12 Dec 2022 18:57:08 +0100 Subject: [PATCH] feat: Unreal Crash Reporter event level (#1677) --- CHANGELOG.md | 1 + relay-server/src/utils/unreal.rs | 49 ++++++++++++++++++++++++++++---- 2 files changed, 45 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8bfcd1f0ce..663198460b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ **Features**: +- The level of events created from Unreal Crash Reports now depends on whether it was an actual crash or an assert. ([#1677](https://github.com/getsentry/relay/pull/1677)) - Dynamic sampling is now based on the volume received by Relay by default and does not include the original volume dropped by client-side sampling in SDKs. This is required for the final dynamic sampling feature in the latest Sentry plans. ([#1591](https://github.com/getsentry/relay/pull/1591)) - Add OpenTelemetry Context ([#1617](https://github.com/getsentry/relay/pull/1617)) - Add `app.in_foreground` and `thread.main` flag to protocol. ([#1578](https://github.com/getsentry/relay/pull/1578)) diff --git a/relay-server/src/utils/unreal.rs b/relay-server/src/utils/unreal.rs index e6921459b1..68b411d1a6 100644 --- a/relay-server/src/utils/unreal.rs +++ b/relay-server/src/utils/unreal.rs @@ -6,8 +6,8 @@ use symbolic_unreal::{ use relay_config::Config; use relay_general::protocol::{ AsPair, Breadcrumb, ClientSdkInfo, Context, Contexts, DeviceContext, Event, EventId, - GpuContext, LenientString, LogEntry, Message, OsContext, TagEntry, Tags, Timestamp, User, - UserReport, Values, + GpuContext, LenientString, Level, LogEntry, Message, OsContext, TagEntry, Tags, Timestamp, + User, UserReport, Values, }; use relay_general::types::{self, Annotated, Array, Object, Value}; @@ -226,6 +226,14 @@ fn merge_unreal_context(event: &mut Event, context: Unreal4Context) { } } + if runtime_props.is_assert.unwrap_or(false) { + event.level = Annotated::new(Level::Error) + } + + if runtime_props.is_ensure.unwrap_or(false) { + event.level = Annotated::new(Level::Warning) + } + // Modules are not used and later replaced with Modules from the Minidump or Apple Crash Report. runtime_props.modules.take(); @@ -314,10 +322,10 @@ pub fn process_unreal_envelope( #[cfg(test)] mod tests { + use super::*; - #[test] - fn test_merge_unreal_context() { + fn get_context() -> Unreal4Context { let raw_context = br##" @@ -346,7 +354,12 @@ mod tests { "##; - let context = Unreal4Context::parse(raw_context).unwrap(); + Unreal4Context::parse(raw_context).unwrap() + } + + #[test] + fn test_merge_unreal_context() { + let context = get_context(); let mut event = Event::default(); merge_unreal_context(&mut event, context); @@ -354,6 +367,32 @@ mod tests { insta::assert_snapshot!(Annotated::new(event).to_json_pretty().unwrap()); } + #[test] + fn test_merge_unreal_context_is_assert_level_error() { + let mut context = get_context(); + let mut runtime_props = context.runtime_properties.as_mut().unwrap(); + runtime_props.is_assert = Some(true); + + let mut event = Event::default(); + + merge_unreal_context(&mut event, context); + + assert_eq!(event.level, Annotated::new(Level::Error)); + } + + #[test] + fn test_merge_unreal_context_is_esure_level_warning() { + let mut context = get_context(); + let mut runtime_props = context.runtime_properties.as_mut().unwrap(); + runtime_props.is_ensure = Some(true); + + let mut event = Event::default(); + + merge_unreal_context(&mut event, context); + + assert_eq!(event.level, Annotated::new(Level::Warning)); + } + #[test] fn test_merge_unreal_logs() { let logs = br##"Log file open, 10/29/18 17:56:37