From 8d37fc63eae489585152b400cbba4a2b91017971 Mon Sep 17 00:00:00 2001 From: lcian <17258265+lcian@users.noreply.github.com> Date: Thu, 30 Oct 2025 11:27:49 +0100 Subject: [PATCH 1/9] feat(backtrace): Stop truncating backtraces --- sentry-backtrace/src/lib.rs | 1 - sentry-backtrace/src/process.rs | 13 +---------- sentry-backtrace/src/trim.rs | 38 --------------------------------- 3 files changed, 1 insertion(+), 51 deletions(-) diff --git a/sentry-backtrace/src/lib.rs b/sentry-backtrace/src/lib.rs index 6b139a51b..ee6c18503 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 90c00335b..4d9318e5b 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, }; @@ -14,17 +14,6 @@ use crate::{Frame, Stacktrace}; /// Trims a `Stacktrace` and 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 ec1087cc6..18499d177 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)) -} From c18475a9da7ee49dfe39346ded0ad9ecbda829f1 Mon Sep 17 00:00:00 2001 From: lcian <17258265+lcian@users.noreply.github.com> Date: Thu, 30 Oct 2025 11:28:39 +0100 Subject: [PATCH 2/9] improve --- sentry-backtrace/src/integration.rs | 4 +--- sentry-core/src/clientoptions.rs | 4 ---- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/sentry-backtrace/src/integration.rs b/sentry-backtrace/src/integration.rs index 5232cdd15..22ee452ed 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-core/src/clientoptions.rs b/sentry-core/src/clientoptions.rs index 33b5bbd4c..5f5bf0be1 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")] From 23003aa53a7424717fb05933da2437c2f8027abe Mon Sep 17 00:00:00 2001 From: lcian <17258265+lcian@users.noreply.github.com> Date: Thu, 30 Oct 2025 11:30:21 +0100 Subject: [PATCH 3/9] improve --- sentry-backtrace/src/process.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/sentry-backtrace/src/process.rs b/sentry-backtrace/src/process.rs index 4d9318e5b..5b468cc5d 100644 --- a/sentry-backtrace/src/process.rs +++ b/sentry-backtrace/src/process.rs @@ -11,8 +11,7 @@ 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 prime in_app and set package let mut any_in_app = false; From 18fbc61c385d7adc63f53e9a01647d20b3b2bc74 Mon Sep 17 00:00:00 2001 From: lcian <17258265+lcian@users.noreply.github.com> Date: Thu, 30 Oct 2025 11:31:01 +0100 Subject: [PATCH 4/9] changelog --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 71621ac13..3660c0cc2 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 From ea994decac7ec698fd7a778355af08797c0b3113 Mon Sep 17 00:00:00 2001 From: lcian <17258265+lcian@users.noreply.github.com> Date: Sun, 23 Nov 2025 19:16:10 +0100 Subject: [PATCH 5/9] wip --- sentry-backtrace/src/trim.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/sentry-backtrace/src/trim.rs b/sentry-backtrace/src/trim.rs index 18499d177..2b1ce260c 100644 --- a/sentry-backtrace/src/trim.rs +++ b/sentry-backtrace/src/trim.rs @@ -10,6 +10,7 @@ const WELL_KNOWN_NOT_IN_APP: &[&str] = &[ "sentry_core::", "sentry_types::", "sentry_backtrace::", + "sentry_tracing::", // these are not modules but things like __rust_maybe_catch_panic "__rust_", "___rust_", From 30c428ab7e285304787e0e228d529f64cd10d87e Mon Sep 17 00:00:00 2001 From: lcian <17258265+lcian@users.noreply.github.com> Date: Sun, 23 Nov 2025 20:06:44 +0100 Subject: [PATCH 6/9] changelog --- CHANGELOG.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3660c0cc2..303a57397 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,9 @@ ### Breaking changes - feat(backtrace): Stop truncating backtraces ([#925](https://github.com/getsentry/sentry-rust/pull/925)) by @lcian - - TODO + - Backtrace trimming functionality has been removed from the SDK. + - Backtrace trimming behavior was previously governed by `ClientOptions::trim_backtraces` (previously set to `true` by default), which has now been removed. + - Moving forward, the SDK will behave as if `trim_backtraces` was set to `false`. ### Fixes From f2d74c295c0d88a6661ac9dd230d8dd63c35d9da Mon Sep 17 00:00:00 2001 From: lcian <17258265+lcian@users.noreply.github.com> Date: Mon, 24 Nov 2025 10:10:25 +0100 Subject: [PATCH 7/9] changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 303a57397..ed86911bb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ - Backtrace trimming functionality has been removed from the SDK. - Backtrace trimming behavior was previously governed by `ClientOptions::trim_backtraces` (previously set to `true` by default), which has now been removed. - Moving forward, the SDK will behave as if `trim_backtraces` was set to `false`. + - If this results in grouping problems (new issues being created for existing errors), please open an issue on [GitHub](https://github.com/getsentry/sentry-rust/issues/new/choose). ### Fixes From 4de32258d0693afd8b79a63fb89bb33c1825685e Mon Sep 17 00:00:00 2001 From: lcian <17258265+lcian@users.noreply.github.com> Date: Mon, 24 Nov 2025 10:25:32 +0100 Subject: [PATCH 8/9] remove extra border frames (thanks cursor) --- sentry-core/src/clientoptions.rs | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/sentry-core/src/clientoptions.rs b/sentry-core/src/clientoptions.rs index 5f5bf0be1..02d5d5a98 100644 --- a/sentry-core/src/clientoptions.rs +++ b/sentry-core/src/clientoptions.rs @@ -189,9 +189,6 @@ pub struct ClientOptions { /// Determine how Sessions are being tracked. #[cfg(feature = "release-health")] pub session_mode: SessionMode, - /// Border frames which indicate a border from a backtrace to - /// useless internals. Some are automatically included. - pub extra_border_frames: Vec<&'static str>, /// The user agent that should be reported. pub user_agent: Cow<'static, str>, } @@ -281,10 +278,7 @@ impl fmt::Debug for ClientOptions { .field("enable_logs", &self.enable_logs) .field("before_send_log", &before_send_log); - debug_struct - .field("extra_border_frames", &self.extra_border_frames) - .field("user_agent", &self.user_agent) - .finish() + debug_struct.field("user_agent", &self.user_agent).finish() } } @@ -317,7 +311,6 @@ impl Default for ClientOptions { auto_session_tracking: false, #[cfg(feature = "release-health")] session_mode: SessionMode::Application, - extra_border_frames: vec![], user_agent: Cow::Borrowed(USER_AGENT), max_request_body_size: MaxRequestBodySize::Medium, #[cfg(feature = "logs")] From ffb2fdae2877662017935f1e9fe998fb7122f38c Mon Sep 17 00:00:00 2001 From: lcian <17258265+lcian@users.noreply.github.com> Date: Mon, 24 Nov 2025 12:58:25 +0100 Subject: [PATCH 9/9] changelog --- CHANGELOG.md | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ed86911bb..25f148e4c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,11 +4,13 @@ ### Breaking changes -- feat(backtrace): Stop truncating backtraces ([#925](https://github.com/getsentry/sentry-rust/pull/925)) by @lcian - - Backtrace trimming functionality has been removed from the SDK. - - Backtrace trimming behavior was previously governed by `ClientOptions::trim_backtraces` (previously set to `true` by default), which has now been removed. - - Moving forward, the SDK will behave as if `trim_backtraces` was set to `false`. - - If this results in grouping problems (new issues being created for existing errors), please open an issue on [GitHub](https://github.com/getsentry/sentry-rust/issues/new/choose). +- Removed the `ClientOptions` struct's `trim_backtraces` and `extra_border_frames` fields ([#925](https://github.com/getsentry/sentry-rust/pull/925)). + - These fields configured backtrace trimming, which is being removed in this release. + +### Improvements + +- Removed backtrace trimming to align the Rust SDK with the general principle that Sentry SDKs should only truncate telemetry data when needed to comply with [documented size limits](https://develop.sentry.dev/sdk/data-model/envelopes/#size-limits) ([#925](https://github.com/getsentry/sentry-rust/pull/925)). This change ensures that as much data as possible remains available for debugging. + - If you notice any new issues being created for existing errors after this change, please open an issue on [GitHub](https://github.com/getsentry/sentry-rust/issues/new/choose). ### Fixes