diff --git a/tracing-error/src/backtrace.rs b/tracing-error/src/backtrace.rs index ba1938d0..0a2c31d2 100644 --- a/tracing-error/src/backtrace.rs +++ b/tracing-error/src/backtrace.rs @@ -69,6 +69,11 @@ pub struct SpanTrace { // === impl SpanTrace === impl SpanTrace { + /// Create a new span trace with the given span as the innermost span. + pub fn new(span: Span) -> Self { + SpanTrace { span } + } + /// Capture the current span trace. /// /// # Examples @@ -96,9 +101,7 @@ impl SpanTrace { /// } /// ``` pub fn capture() -> Self { - SpanTrace { - span: Span::current(), - } + SpanTrace::new(Span::current()) } /// Apply a function to all captured spans in the trace until it returns