BacktraceCollector

Struct BacktraceCollector 

Source
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: BacktraceFilter

Configuration for filtering and formatting backtrace frames.

§capture_backtrace_for_reports_with_children: bool

If 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

Source

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 frames
  • ROOTCAUSE_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

Source§

fn clone(&self) -> BacktraceCollector

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl ReportCreationHook for BacktraceCollector

Source§

fn on_local_creation(&self, report: ReportMut<'_, Dynamic, Local>)

Called when a Local report is created.
Source§

fn on_sendsync_creation(&self, report: ReportMut<'_, Dynamic, SendSync>)

Called when a SendSync report is created.
Source§

impl Copy for BacktraceCollector

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<O> ObjectMarkerFor<Local> for O
where O: 'static,

Source§

impl<O> ObjectMarkerFor<SendSync> for O
where O: 'static + Send + Sync,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.