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§
source§impl 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.