pub struct SchemaObserver { /* private fields */ }Expand description
Opt-in counter that classifies each observed event and tallies per-schema
(and unknown) totals. Mirrors the design of FieldObserver:
shared behind an Arc, cheap repeated snapshots, monotonic lifetime
counters for a Prometheus bridge. The schema set is small and bounded, so
there is no key cap.
Implementations§
Source§impl SchemaObserver
impl SchemaObserver
Sourcepub fn new(classifier: SchemaClassifier) -> Self
pub fn new(classifier: SchemaClassifier) -> Self
Create an observer backed by the given classifier.
Sourcepub fn observe<E: Event + ?Sized>(&self, event: &E)
pub fn observe<E: Event + ?Sized>(&self, event: &E)
Classify an event and update the counters. Takes &self so the
observer can be shared behind an Arc.
Sourcepub fn snapshot(&self) -> SchemaObservation
pub fn snapshot(&self) -> SchemaObservation
Snapshot the current counts, sorted by descending count then name.
Sourcepub fn reset(&self) -> (u64, u64)
pub fn reset(&self) -> (u64, u64)
Reset the since-last-reset counters (lifetime totals are preserved).
Returns the previous (classified, unknown) pair.
Sourcepub fn lifetime_classified(&self) -> u64
pub fn lifetime_classified(&self) -> u64
Lifetime classified total, ignoring resets. Monotonic.
Sourcepub fn lifetime_unknown(&self) -> u64
pub fn lifetime_unknown(&self) -> u64
Lifetime unknown total, ignoring resets. Monotonic.
Auto Trait Implementations§
impl !Freeze for SchemaObserver
impl RefUnwindSafe for SchemaObserver
impl Send for SchemaObserver
impl Sync for SchemaObserver
impl Unpin for SchemaObserver
impl UnsafeUnpin for SchemaObserver
impl UnwindSafe for SchemaObserver
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