Struct metrics_util::debugging::DebuggingRecorder
source · [−]pub struct DebuggingRecorder { /* private fields */ }
Expand description
A simplistic recorder that can be installed and used for debugging or testing.
Callers can easily take snapshots of the metrics at any given time and get access to the raw values.
Implementations
sourceimpl DebuggingRecorder
impl DebuggingRecorder
sourcepub fn new() -> DebuggingRecorder
pub fn new() -> DebuggingRecorder
Creates a new DebuggingRecorder
.
sourcepub fn per_thread() -> DebuggingRecorder
pub fn per_thread() -> DebuggingRecorder
Creates a new DebuggingRecorder
in per-thread mode.
This sends all metrics to a per-thread registry, such that the snapshotter will only see metrics emitted in the
thread that the Snapshotter
is used from. Additionally, as keeping a reference to the original Snapshotter
around can be tricky, Snapshotter::current_thread_snapshot
can be used to get all of the metrics currently
present in the registry for the calling thread, if any were emitted.
Please note that this recorder must still be installed, but it can be installed multiple times (if the error
from install
is ignored) without clearing or removing any of the existing per-thread metrics, so it’s safe to
re-create and re-install multiple times in the same test binary if necessary.
sourcepub fn snapshotter(&self) -> Snapshotter
pub fn snapshotter(&self) -> Snapshotter
Gets a Snapshotter
attached to this recorder.
sourcepub fn install(self) -> Result<(), SetRecorderError>
pub fn install(self) -> Result<(), SetRecorderError>
Installs this recorder as the global recorder.
Trait Implementations
sourceimpl Default for DebuggingRecorder
impl Default for DebuggingRecorder
sourceimpl Recorder for DebuggingRecorder
impl Recorder for DebuggingRecorder
sourcefn describe_counter(
&self,
key: KeyName,
unit: Option<Unit>,
description: SharedString
)
fn describe_counter(
&self,
key: KeyName,
unit: Option<Unit>,
description: SharedString
)
Describes a counter. Read more
sourcefn describe_gauge(
&self,
key: KeyName,
unit: Option<Unit>,
description: SharedString
)
fn describe_gauge(
&self,
key: KeyName,
unit: Option<Unit>,
description: SharedString
)
Describes a gauge. Read more
sourcefn describe_histogram(
&self,
key: KeyName,
unit: Option<Unit>,
description: SharedString
)
fn describe_histogram(
&self,
key: KeyName,
unit: Option<Unit>,
description: SharedString
)
Describes a histogram. Read more
sourcefn register_counter(&self, key: &Key) -> Counter
fn register_counter(&self, key: &Key) -> Counter
Registers a counter.
sourcefn register_gauge(&self, key: &Key) -> Gauge
fn register_gauge(&self, key: &Key) -> Gauge
Registers a gauge.
sourcefn register_histogram(&self, key: &Key) -> Histogram
fn register_histogram(&self, key: &Key) -> Histogram
Registers a histogram.
Auto Trait Implementations
impl !RefUnwindSafe for DebuggingRecorder
impl Send for DebuggingRecorder
impl Sync for DebuggingRecorder
impl Unpin for DebuggingRecorder
impl !UnwindSafe for DebuggingRecorder
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more