pub struct YoshiBacktrace { /* private fields */ }std only.Expand description
Performance-optimized backtrace wrapper with metadata.
This struct wraps std::backtrace::Backtrace (available with the std feature)
and augments it with additional metadata such as capture timestamp, thread ID,
thread name, and the performance cost of capturing the backtrace.
It is designed for efficient debugging and performance analysis in production.
Implementations§
Source§impl YoshiBacktrace
impl YoshiBacktrace
Sourcepub fn new_captured() -> Self
pub fn new_captured() -> Self
Captures a new backtrace with performance monitoring.
This static method performs the actual capture of the backtrace, measures the time taken for the capture, and records thread information.
§Returns
A new YoshiBacktrace instance containing the captured backtrace
and associated metadata.
§Examples
let bt = YoshiBacktrace::new_captured();
println!("Backtrace captured at {:?}", bt.capture_cost_nanos());Sourcepub fn status(&self) -> BacktraceStatus
pub fn status(&self) -> BacktraceStatus
Returns the status of the inner backtrace.
This method delegates to std::backtrace::Backtrace::status() to
indicate whether the backtrace was successfully captured, disabled,
or if some error occurred during capture.
§Returns
A std::backtrace::BacktraceStatus enum.
§Examples
let bt = YoshiBacktrace::new_captured();
match bt.status() {
BacktraceStatus::Captured => println!("Backtrace captured successfully."),
BacktraceStatus::Disabled => println!("Backtrace capture was disabled."),
_ => println!("Backtrace status: {:?}", bt.status()),
}Sourcepub fn capture_cost_nanos(&self) -> Option<u64>
pub fn capture_cost_nanos(&self) -> Option<u64>
Gets the capture cost in nanoseconds.
This provides a metric for the performance overhead incurred when capturing the backtrace.
§Returns
An Option<u64> containing the capture cost in nanoseconds, or None
if the cost was not measured (e.g., if backtrace capture was disabled).
§Examples
let bt = YoshiBacktrace::new_captured();
if let Some(cost) = bt.capture_cost_nanos() {
println!("Backtrace capture took {} ns", cost);
}