Skip to content

Commit

Permalink
feat: allow creating SpanTrace from Span directly
Browse files Browse the repository at this point in the history
  • Loading branch information
CAD97 committed Aug 5, 2021
1 parent e0db056 commit 1999b9c
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions tracing-error/src/backtrace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 1999b9c

Please sign in to comment.