diff --git a/tracing-error/src/backtrace.rs b/tracing-error/src/backtrace.rs index ba56e189a1..16335d17b4 100644 --- a/tracing-error/src/backtrace.rs +++ b/tracing-error/src/backtrace.rs @@ -68,6 +68,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 @@ -95,9 +100,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