pub struct Timeline { /* private fields */ }Expand description
A record of boot phases. See the module documentation.
Implementations§
Source§impl Timeline
impl Timeline
Sourcepub fn new() -> Self
pub fn new() -> Self
A timeline whose origin is now. Services use Timeline::global;
this exists for tests and for embedding a second, independent boot.
Sourcepub fn global() -> &'static Self
pub fn global() -> &'static Self
The process-wide timeline, whose origin is the process’s start time where the platform reports it (Linux) and its first use otherwise.
Sourcepub fn set_service_name(&self, name: &str)
pub fn set_service_name(&self, name: &str)
Name the service in the stderr lines. Without it the lines use
OTEL_SERVICE_NAME, then the executable’s name, until
Timeline::flush supplies the telemetry service name.
Sourcepub fn phase(&self, name: impl Into<Cow<'static, str>>) -> PhaseGuard<'_>
pub fn phase(&self, name: impl Into<Cow<'static, str>>) -> PhaseGuard<'_>
Start timing a phase. The phase is recorded when the guard is
finished or, as Outcome::Failed, when it is
dropped unfinished.
Sourcepub async fn time<F: IntoFuture>(
&self,
name: impl Into<Cow<'static, str>>,
work: F,
) -> F::Output
pub async fn time<F: IntoFuture>( &self, name: impl Into<Cow<'static, str>>, work: F, ) -> F::Output
Time work as one phase. If the future is dropped before completing,
the phase is recorded as Outcome::Failed.
Sourcepub async fn try_time<T, E, F>(
&self,
name: impl Into<Cow<'static, str>>,
work: F,
) -> Result<T, E>where
F: IntoFuture<Output = Result<T, E>>,
pub async fn try_time<T, E, F>(
&self,
name: impl Into<Cow<'static, str>>,
work: F,
) -> Result<T, E>where
F: IntoFuture<Output = Result<T, E>>,
Like Timeline::time, recording Outcome::Failed when work
returns Err.
Sourcepub fn ready(&self)
pub fn ready(&self)
Mark boot complete: writes the phase=ready line and ends the boot
root span. Only the first call counts.
Sourcepub fn flush(&self, provider: &SdkTracerProvider, service_name: &str) -> usize
pub fn flush(&self, provider: &SdkTracerProvider, service_name: &str) -> usize
Connect the timeline to provider: export every buffered phase as a
span with its original timestamps under the boot root span, emit a
log event for each, and export later phases as they complete.
Idempotent: the first provider wins, and a later call exports nothing
and returns 0. Returns the number of phases exported by this call.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for Timeline
impl RefUnwindSafe for Timeline
impl Send for Timeline
impl Sync for Timeline
impl Unpin for Timeline
impl UnsafeUnpin for Timeline
impl UnwindSafe for Timeline
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
Source§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
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> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request