Skip to content

Commit

Permalink
Allow resetting span start time
Browse files Browse the repository at this point in the history
This is especially useful with futures when you can
create a future and a span, but only want to start
the span when future is first polled.
  • Loading branch information
bobrik committed Feb 1, 2020
1 parent 71ca7e5 commit 4937905
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/span.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,16 @@ impl<T> Span<T> {
}
}

/// Sets the start time of this span.
pub fn set_start_time<F>(&mut self, f: F)
where
F: FnOnce() -> SystemTime,
{
if let Some(inner) = self.0.as_mut() {
inner.start_time = f();
}
}

/// Sets the finish time of this span.
pub fn set_finish_time<F>(&mut self, f: F)
where
Expand Down

0 comments on commit 4937905

Please sign in to comment.