diff --git a/sentry-backtrace/src/process.rs b/sentry-backtrace/src/process.rs index 82334c9a7..90c00335b 100644 --- a/sentry-backtrace/src/process.rs +++ b/sentry-backtrace/src/process.rs @@ -3,7 +3,7 @@ use std::borrow::Cow; use backtrace::Backtrace; use sentry_core::ClientOptions; -use crate::trim::{is_sys_function, trim_stacktrace}; +use crate::trim::{is_well_known_not_in_app, trim_stacktrace}; use crate::utils::{ demangle_symbol, filename, function_starts_with, parse_crate_name, strip_symbol, }; @@ -72,7 +72,7 @@ pub fn process_event_stacktrace(stacktrace: &mut Stacktrace, options: &ClientOpt continue; } - if is_sys_function(func_name) { + if is_well_known_not_in_app(func_name) { frame.in_app = Some(false); } } diff --git a/sentry-backtrace/src/trim.rs b/sentry-backtrace/src/trim.rs index d74150054..b1326bee5 100644 --- a/sentry-backtrace/src/trim.rs +++ b/sentry-backtrace/src/trim.rs @@ -2,7 +2,8 @@ use sentry_core::protocol::{Frame, Stacktrace}; use crate::utils::function_starts_with; -const WELL_KNOWN_SYS_MODULES: &[&str] = &[ +const WELL_KNOWN_NOT_IN_APP: &[&str] = &[ + // standard library and sentry crates "std::", "core::", "alloc::", @@ -13,11 +14,14 @@ const WELL_KNOWN_SYS_MODULES: &[&str] = &[ // these are not modules but things like __rust_maybe_catch_panic "__rust_", "___rust_", + "rust_begin_unwind", // these are well-known library frames "anyhow::", "log::", "tokio::", "tracing_core::", + "futures_core::", + "futures_util::", ]; const WELL_KNOWN_BORDER_FRAMES: &[&str] = &[ @@ -39,7 +43,7 @@ where .iter() .rev() .position(|frame| match frame.function { - Some(ref func) => is_well_known(func) || f(frame, stacktrace), + Some(ref func) => is_well_known_border_frame(func) || f(frame, stacktrace), None => false, }); @@ -49,15 +53,15 @@ where } } -/// Checks if a function is considered to be not in-app -pub fn is_sys_function(func: &str) -> bool { - WELL_KNOWN_SYS_MODULES +/// Checks if a function is from a module that shall be considered not in-app by default +pub fn is_well_known_not_in_app(func: &str) -> bool { + WELL_KNOWN_NOT_IN_APP .iter() .any(|m| function_starts_with(func, m)) } -/// Checks if a function is a well-known system function -fn is_well_known(func: &str) -> bool { +/// Checks if a function is a well-known border frame +fn is_well_known_border_frame(func: &str) -> bool { WELL_KNOWN_BORDER_FRAMES .iter() .any(|m| function_starts_with(func, m)) diff --git a/sentry-backtrace/src/utils.rs b/sentry-backtrace/src/utils.rs index 6b018ff50..f638eed45 100644 --- a/sentry-backtrace/src/utils.rs +++ b/sentry-backtrace/src/utils.rs @@ -97,12 +97,15 @@ pub fn demangle_symbol(s: &str) -> String { /// /// In trait implementations, the original type name is wrapped in "_< ... >" and colons are /// replaced with dots. This function accounts for differences while checking. +/// The ` bool { if pattern.starts_with('<') { while pattern.starts_with('<') { pattern = &pattern[1..]; - if func_name.starts_with('<') { + if func_name.starts_with(" bool { } } } else { - func_name = func_name.trim_start_matches('<').trim_start_matches("_<"); + func_name = func_name + .trim_start_matches("