pub struct BacktraceCollector {
pub filter: BacktraceFilter,
pub capture_backtrace_for_reports_with_children: bool,
}Expand description
Attachment collector for capturing stack backtraces.
When registered as a report creation hook, this collector automatically
captures the current stack backtrace and attaches it as a Backtrace
attachment.
§Examples
Basic usage with default settings:
use rootcause::hooks::Hooks;
use rootcause_backtrace::BacktraceCollector;
Hooks::new()
.report_creation_hook(BacktraceCollector::new_from_env())
.install()
.expect("failed to install hooks");Custom configuration:
use rootcause::hooks::Hooks;
use rootcause_backtrace::{BacktraceCollector, BacktraceFilter};
let collector = BacktraceCollector {
filter: BacktraceFilter {
skipped_initial_crates: &[],
skipped_middle_crates: &[],
skipped_final_crates: &[],
max_entry_count: 30,
show_full_path: true,
},
capture_backtrace_for_reports_with_children: true,
};
Hooks::new()
.report_creation_hook(collector)
.install()
.expect("failed to install hooks");Fields§
§filter: BacktraceFilterConfiguration for filtering and formatting backtrace frames.
capture_backtrace_for_reports_with_children: boolIf set to true, a backtrace is captured for every report creation, including reports that have child reports (i.e., reports created with existing children). If set to false, a backtrace is captured only for reports created without any children. Reports created without children always receive a backtrace regardless of this setting.
Implementations§
Source§impl BacktraceCollector
impl BacktraceCollector
Sourcepub fn new_from_env() -> Self
pub fn new_from_env() -> Self
Creates a new BacktraceCollector with default settings.
Configuration is controlled by environment variables. By default, filtering is applied and backtraces are only captured for reports without children.
§Environment Variables
RUST_BACKTRACE=full- Disables all filtering and shows all framesROOTCAUSE_BACKTRACE- Comma-separated options:leafs- Only capture backtraces for leaf errors (errors without children)full_paths- Show full file paths instead of shortened paths
The RUST_BACKTRACE=full setting implies full_paths unless explicitly
overridden by ROOTCAUSE_BACKTRACE.
§Examples
use rootcause::hooks::Hooks;
use rootcause_backtrace::BacktraceCollector;
// Respects RUST_BACKTRACE and ROOTCAUSE_BACKTRACE environment variables
Hooks::new()
.report_creation_hook(BacktraceCollector::new_from_env())
.install()
.expect("failed to install hooks");Trait Implementations§
Source§impl Clone for BacktraceCollector
impl Clone for BacktraceCollector
Source§fn clone(&self) -> BacktraceCollector
fn clone(&self) -> BacktraceCollector
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more