[−][src]Trait opentracingrust::utils::FailSpan
Trait to make failing spans on error easier and nicer.
The most common use is for Result
instances in combination with the ?
operator.
Examples
extern crate opentracingrust; use std::num::ParseIntError; use opentracingrust::Span; use opentracingrust::tracers::NoopTracer; use opentracingrust::utils::FailSpan; fn work(mut span: &mut Span) -> Result<i32, ParseIntError> { let ten: i32 = "10".parse().fail_span(&mut span)?; let two: i32 = "2".parse().fail_span(&mut span)?; Ok(ten * two) } fn main() { let (tracer, _) = NoopTracer::new(); let mut span = tracer.span("test"); let result = work(&mut span).unwrap(); println!("{}", result); }
Associated Types
Loading content...Required methods
fn error(&self) -> Option<&Self::Error>
Access the current error information, if any.
Returns None
if there was no error.
fn fail_span<S>(self, span: S) -> Self where
S: AsMut<Span>,
S: AsMut<Span>,
Tags a span as failed if there was an error.
An error
event should also be logged with the details
following the OpenTracing specification.
Nothing is done if there was no error (error()
returns None
).
Implementations on Foreign Types
impl<T, E> FailSpan for Result<T, E> where
E: Error,
[src]
E: Error,
type Error = E
fn error(&self) -> Option<&E>
[src]
fn fail_span<S>(self, span: S) -> Result<T, E> where
S: AsMut<Span>,
[src]
S: AsMut<Span>,