pub struct Span(/* private fields */);Expand description
Annotates a timespan during a Capture.
Constructing and dropping a Span, when marker spans are being captured with Capture, records the start and end times of the Span along with a name, category, and tooltip.
Span is for timespans. Use Event for point-in-time events.
When Capture is not active, Span has minimal overhead.
Implementations§
Source§impl Span
impl Span
Sourcepub fn new(name: &'static str) -> Self
pub fn new(name: &'static str) -> Self
Constructs a new Span with the given name. When the constructed span is dropped, it is automatically recorded.
Span does nothing when markers are not being captured. A span will be recorded in a profile only if markers were being captured both when it was created and when it was dropped.
The name should ordinarily be a short static string indicating what happens during the span. The Firefox Profiler’s marker chart view shows all the spans in a thread with the same name and category on a single horizontal timeline (unless that would cause overlaps).
Sourcepub fn with_category(self, category: &'static str) -> Self
pub fn with_category(self, category: &'static str) -> Self
Adds category to this span.
The Firefox Profiler’s marker chart view groups the markers in each category and labels them with the category name.
The default category is “Other”.
Sourcepub fn with_tooltip<F>(self, tooltip: F) -> Self
pub fn with_tooltip<F>(self, tooltip: F) -> Self
Evaluates tooltip and adds it to this span.
The Firefox Profiler shows the given tooltip in the marker chart timeline (often truncated) and on hover, and as “details” in the marker table view.
tooltip is only evaluated if capturing is active.
Sourcepub fn with_start(self, start: Instant) -> Self
pub fn with_start(self, start: Instant) -> Self
Sets the starting time for this span to start. The default starting
time is when the Span was constructed, so this is only useful if
it’s easier to create the span just before recording it.
Trait Implementations§
Auto Trait Implementations§
impl Forget for Span
impl Freeze for Span
impl RefUnwindSafe for Span
impl Send for Span
impl Sync for Span
impl Unpin for Span
impl UnsafeUnpin for Span
impl UnwindSafe for Span
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more