Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 1 addition & 3 deletions sentry-backtrace/src/integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 0 additions & 1 deletion sentry-backtrace/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
16 changes: 2 additions & 14 deletions sentry-backtrace/src/process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,16 @@ 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,
};
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 {
Expand Down
38 changes: 0 additions & 38 deletions sentry-backtrace/src/trim.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
use sentry_core::protocol::{Frame, Stacktrace};

use crate::utils::function_starts_with;

const WELL_KNOWN_NOT_IN_APP: &[&str] = &[
Expand All @@ -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::",
"<sentry_log::Logger as log::Log>::log",
"tracing_core::",
];

/// A helper function to trim a stacktrace.
pub fn trim_stacktrace<F>(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))
}
4 changes: 0 additions & 4 deletions sentry-core/src/clientoptions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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>,
}
Expand Down Expand Up @@ -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()
}
Expand Down Expand Up @@ -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")]
Expand Down
Loading