pub struct Timestamp { /* private fields */ }Expand description
Timestamp of a metric entry
This type should with #[metrics(timestamp)] attribute on the root of your metrics entry.
Unless otherwise specified, it will record the time that it was created at. If you need to record a different time,
use Timestamp::new.
When used as a field (without the #[metrics(timestamp)] attribute), Timestamp will record a value field (not a metric)
containing the current timestamp. By default, Timestamp will report units of Millisecond. You can control the unit with the unit attribute.
Implementations§
Source§impl Timestamp
impl Timestamp
Sourcepub fn now() -> Self
pub fn now() -> Self
Create a new timestamp at the current time.
The time will be loaded from metrique_timesource::time_source
This is the behavior of Timestamp::default
Sourcepub fn new(time: SystemTime) -> Self
pub fn new(time: SystemTime) -> Self
Create a new timestamp at a specific time
Sourcepub fn new_from_time_source(ts: TimeSource) -> Self
pub fn new_from_time_source(ts: TimeSource) -> Self
Create a new timestamp at a specific time from an explicit TimeSource
§Examples
use std::time::UNIX_EPOCH;
use metrique_timesource::{TimeSource, fakes::StaticTimeSource};
use metrique::timers::Timestamp;
let ts = TimeSource::custom(StaticTimeSource::at_time(UNIX_EPOCH));
let timestamp = Timestamp::new_from_time_source(ts);Trait Implementations§
Source§impl CloseValue for &Timestamp
impl CloseValue for &Timestamp
Source§impl CloseValue for Timestamp
impl CloseValue for Timestamp
Auto Trait Implementations§
impl Freeze for Timestamp
impl RefUnwindSafe for Timestamp
impl Send for Timestamp
impl Sync for Timestamp
impl Unpin for Timestamp
impl UnwindSafe for Timestamp
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<C, T> CloseValueRef for Twhere
&'a T: for<'a> CloseValue<Closed = C>,
impl<C, T> CloseValueRef for Twhere
&'a T: for<'a> CloseValue<Closed = C>,
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<V, F> ValueFormatter<&V> for F
impl<V, F> ValueFormatter<&V> for F
Source§fn format_value(writer: impl ValueWriter, value: &&V)
fn format_value(writer: impl ValueWriter, value: &&V)
value to writerSource§impl<V, F> ValueFormatter<Arc<V>> for F
impl<V, F> ValueFormatter<Arc<V>> for F
Source§fn format_value(writer: impl ValueWriter, value: &Arc<V>)
fn format_value(writer: impl ValueWriter, value: &Arc<V>)
value to writerSource§impl<V, F> ValueFormatter<Box<V>> for F
impl<V, F> ValueFormatter<Box<V>> for F
Source§fn format_value(writer: impl ValueWriter, value: &Box<V>)
fn format_value(writer: impl ValueWriter, value: &Box<V>)
value to writerSource§impl<V, F> ValueFormatter<Cow<'_, V>> for F
impl<V, F> ValueFormatter<Cow<'_, V>> for F
Source§fn format_value(writer: impl ValueWriter, value: &Cow<'_, V>)
fn format_value(writer: impl ValueWriter, value: &Cow<'_, V>)
value to writerSource§impl<V, F> ValueFormatter<Option<V>> for Fwhere
F: ValueFormatter<V> + ?Sized,
impl<V, F> ValueFormatter<Option<V>> for Fwhere
F: ValueFormatter<V> + ?Sized,
Source§fn format_value(writer: impl ValueWriter, value: &Option<V>)
fn format_value(writer: impl ValueWriter, value: &Option<V>)
value to writer