pub trait SpanExt: Sized {
// Required method
fn attach_span(self) -> Self;
}Expand description
Extension trait for attaching tracing spans to reports.
This trait provides methods to easily attach the current tracing span
to a report or to the error contained within a Result.
§Examples
Attach tracing span to a report:
use rootcause::report;
use rootcause_tracing::SpanExt;
#[tracing::instrument]
fn example() {
let report = report!("An error occurred").attach_span();
}Attach tracing span to a Result:
use rootcause::{Report, report};
use rootcause_tracing::SpanExt;
#[tracing::instrument]
fn might_fail() -> Result<(), Report> {
Err(report!("operation failed").into_dynamic())
}
let result = might_fail().attach_span();Required Methods§
Sourcefn attach_span(self) -> Self
fn attach_span(self) -> Self
Attaches the current tracing span to the report.
§Examples
use rootcause::report;
use rootcause_tracing::SpanExt;
#[tracing::instrument]
fn example() {
let report = report!("error").attach_span();
}Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.