Skip to content

Commit

Permalink
feat: Unreal Crash Reporter event level (#1677)
Browse files Browse the repository at this point in the history
  • Loading branch information
bitsandfoxes authored Dec 12, 2022
1 parent 1078cda commit f884122
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
49 changes: 44 additions & 5 deletions relay-server/src/utils/unreal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};

Expand Down Expand Up @@ -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();

Expand Down Expand Up @@ -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##"<?xml version="1.0" encoding="UTF-8"?>
<FGenericCrashContext>
<RuntimeProperties>
Expand Down Expand Up @@ -346,14 +354,45 @@ mod tests {
</FGenericCrashContext>
"##;

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);

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
Expand Down

0 comments on commit f884122

Please sign in to comment.