pub struct RecordingSink { /* private fields */ }Expand description
Append-only in-memory sink for assertions in unit and integration tests.
Clones share the same captured data. Use the typed accessors to inspect all emits or the matching helpers to select one metric name, label subset, or event table.
§Examples
use spectra_core::{RecordingSink, SpectraSink};
let sink = RecordingSink::new();
sink.record_counter("cache_hits", &[("region", "us")], 2);
let hits = sink.recorded_counters_matching("cache_hits", &[("region", "us")]);
assert_eq!(hits.len(), 1);
assert_eq!(hits[0].delta, 2);
sink.clear();
assert!(sink.counters().is_empty());Implementations§
Source§impl RecordingSink
impl RecordingSink
Sourcepub fn new() -> RecordingSink
pub fn new() -> RecordingSink
Creates an empty recording sink.
Sourcepub fn recorded_counters_matching(
&self,
name: &str,
label_subset: &[(&str, &str)],
) -> Vec<RecordedCounter>
pub fn recorded_counters_matching( &self, name: &str, label_subset: &[(&str, &str)], ) -> Vec<RecordedCounter>
Returns counters matching a name and label subset.
Sourcepub fn recorded_events_for(&self, table: &str) -> Vec<RecordedEvent>
pub fn recorded_events_for(&self, table: &str) -> Vec<RecordedEvent>
Returns events recorded for a specific table.
Trait Implementations§
Source§impl Clone for RecordingSink
impl Clone for RecordingSink
Source§fn clone(&self) -> RecordingSink
fn clone(&self) -> RecordingSink
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for RecordingSink
impl Debug for RecordingSink
Source§impl Default for RecordingSink
impl Default for RecordingSink
Source§fn default() -> RecordingSink
fn default() -> RecordingSink
Returns the “default value” for a type. Read more
Source§impl SpectraSink for RecordingSink
impl SpectraSink for RecordingSink
Auto Trait Implementations§
impl Freeze for RecordingSink
impl RefUnwindSafe for RecordingSink
impl Send for RecordingSink
impl Sync for RecordingSink
impl Unpin for RecordingSink
impl UnsafeUnpin for RecordingSink
impl UnwindSafe for RecordingSink
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
Mutably borrows from an owned value. Read more