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) -> SchemaObserver
pub fn new(classifier: SchemaClassifier) -> SchemaObserver
Create an observer backed by the given classifier.
Sourcepub fn builtin() -> SchemaObserver
pub fn builtin() -> SchemaObserver
Create an observer using the built-in classifier.
Sourcepub fn observe<E>(&self, event: &E)
pub fn observe<E>(&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> AnyExt for T
impl<T> AnyExt for T
Source§fn downcast_ref<T>(this: &Self) -> Option<&T>where
T: Any,
fn downcast_ref<T>(this: &Self) -> Option<&T>where
T: Any,
T behind referenceSource§fn downcast_mut<T>(this: &mut Self) -> Option<&mut T>where
T: Any,
fn downcast_mut<T>(this: &mut Self) -> Option<&mut T>where
T: Any,
T behind mutable referenceSource§fn downcast_rc<T>(this: Rc<Self>) -> Result<Rc<T>, Rc<Self>>where
T: Any,
fn downcast_rc<T>(this: Rc<Self>) -> Result<Rc<T>, Rc<Self>>where
T: Any,
T behind Rc pointerSource§fn downcast_arc<T>(this: Arc<Self>) -> Result<Arc<T>, Arc<Self>>where
T: Any,
fn downcast_arc<T>(this: Arc<Self>) -> Result<Arc<T>, Arc<Self>>where
T: Any,
T behind Arc pointerSource§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<T, X> CoerceTo<T> for Xwhere
T: CoerceFrom<X> + ?Sized,
impl<T, X> CoerceTo<T> for Xwhere
T: CoerceFrom<X> + ?Sized,
fn coerce_rc_to(self: Rc<X>) -> Rc<T>
fn coerce_box_to(self: Box<X>) -> Box<T>
fn coerce_ref_to(&self) -> &T
fn coerce_mut_to(&mut self) -> &mut T
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 more