diff --git a/CHANGELOG.md b/CHANGELOG.md index 71621ac1..3660c0cc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,11 @@ ## Unreleased +### Breaking changes + +- feat(backtrace): Stop truncating backtraces ([#925](https://github.com/getsentry/sentry-rust/pull/925)) by @lcian + - TODO + ### Fixes - fix: adjust sentry.origin for log integration ([#919](https://github.com/getsentry/sentry-rust/pull/919)) by @lcian diff --git a/sentry-backtrace/src/integration.rs b/sentry-backtrace/src/integration.rs index 5232cdd1..22ee452e 100644 --- a/sentry-backtrace/src/integration.rs +++ b/sentry-backtrace/src/integration.rs @@ -8,9 +8,7 @@ use crate::process::process_event_stacktrace; /// Integration to process Event stacktraces. /// -/// This integration will trim backtraces, depending on the `trim_backtraces` -/// and `extra_border_frames` options. -/// It will then classify each frame according to the `in_app_include` and +/// This integration will classify each frame according to the `in_app_include` and /// `in_app_exclude` options. #[derive(Debug, Default)] pub struct ProcessStacktraceIntegration; diff --git a/sentry-backtrace/src/lib.rs b/sentry-backtrace/src/lib.rs index 6b139a51..ee6c1850 100644 --- a/sentry-backtrace/src/lib.rs +++ b/sentry-backtrace/src/lib.rs @@ -18,7 +18,6 @@ pub use crate::integration::{ }; pub use crate::parse::parse_stacktrace; pub use crate::process::{backtrace_to_stacktrace, process_event_stacktrace}; -pub use crate::trim::trim_stacktrace; pub use sentry_core::protocol::{Frame, Stacktrace}; /// Returns the current backtrace as sentry stacktrace. diff --git a/sentry-backtrace/src/process.rs b/sentry-backtrace/src/process.rs index 90c00335..5b468cc5 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_well_known_not_in_app, trim_stacktrace}; +use crate::trim::is_well_known_not_in_app; use crate::utils::{ demangle_symbol, filename, function_starts_with, parse_crate_name, strip_symbol, }; @@ -11,20 +11,8 @@ use crate::{Frame, Stacktrace}; /// Processes a `Stacktrace`. /// -/// Trims a `Stacktrace` and marks frames as in-app based on the provided -/// `ClientOptions`. +/// Marks frames as in-app based on the provided `ClientOptions`. pub fn process_event_stacktrace(stacktrace: &mut Stacktrace, options: &ClientOptions) { - // automatically trim backtraces - if options.trim_backtraces { - trim_stacktrace(stacktrace, |frame, _| { - if let Some(ref func) = frame.function { - options.extra_border_frames.contains(&func.as_str()) - } else { - false - } - }) - } - // automatically prime in_app and set package let mut any_in_app = false; for frame in &mut stacktrace.frames { diff --git a/sentry-backtrace/src/trim.rs b/sentry-backtrace/src/trim.rs index ec1087cc..18499d17 100644 --- a/sentry-backtrace/src/trim.rs +++ b/sentry-backtrace/src/trim.rs @@ -1,5 +1,3 @@ -use sentry_core::protocol::{Frame, Stacktrace}; - use crate::utils::function_starts_with; const WELL_KNOWN_NOT_IN_APP: &[&str] = &[ @@ -26,45 +24,9 @@ const WELL_KNOWN_NOT_IN_APP: &[&str] = &[ "futures_util::", ]; -const WELL_KNOWN_BORDER_FRAMES: &[&str] = &[ - "std::panicking::begin_panic", - "core::panicking::panic", - // well-known library frames - "anyhow::", - "::log", - "tracing_core::", -]; - -/// A helper function to trim a stacktrace. -pub fn trim_stacktrace(stacktrace: &mut Stacktrace, f: F) -where - F: Fn(&Frame, &Stacktrace) -> bool, -{ - let known_cutoff = stacktrace - .frames - .iter() - .rev() - .position(|frame| match frame.function { - Some(ref func) => is_well_known_border_frame(func) || f(frame, stacktrace), - None => false, - }); - - if let Some(cutoff) = known_cutoff { - let trunc = stacktrace.frames.len() - cutoff - 1; - stacktrace.frames.truncate(trunc); - } -} - /// 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 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-core/src/clientoptions.rs b/sentry-core/src/clientoptions.rs index 33b5bbd4..5f5bf0be 100644 --- a/sentry-core/src/clientoptions.rs +++ b/sentry-core/src/clientoptions.rs @@ -192,8 +192,6 @@ pub struct ClientOptions { /// Border frames which indicate a border from a backtrace to /// useless internals. Some are automatically included. pub extra_border_frames: Vec<&'static str>, - /// Automatically trim backtraces of junk before sending. (defaults to true) - pub trim_backtraces: bool, /// The user agent that should be reported. pub user_agent: Cow<'static, str>, } @@ -285,7 +283,6 @@ impl fmt::Debug for ClientOptions { debug_struct .field("extra_border_frames", &self.extra_border_frames) - .field("trim_backtraces", &self.trim_backtraces) .field("user_agent", &self.user_agent) .finish() } @@ -321,7 +318,6 @@ impl Default for ClientOptions { #[cfg(feature = "release-health")] session_mode: SessionMode::Application, extra_border_frames: vec![], - trim_backtraces: true, user_agent: Cow::Borrowed(USER_AGENT), max_request_body_size: MaxRequestBodySize::Medium, #[cfg(feature = "logs")]