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 (discovery sampling off).
Sourcepub fn new_with_discovery(
classifier: SchemaClassifier,
discovery_sampling: bool,
) -> Self
pub fn new_with_discovery( classifier: SchemaClassifier, discovery_sampling: bool, ) -> Self
Create an observer, optionally enabling the discovery sampler that
records redacted shapes of generic_json and no-match events for
schema signature discovery.
Sourcepub fn discovery_sampling(&self) -> bool
pub fn discovery_sampling(&self) -> bool
Whether the discovery sampler (recording unrecognized-event shapes into
SchemaObservation::unrecognized_shapes) is on.
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.
Sourcepub fn lifetime_ambiguous(&self) -> u64
pub fn lifetime_ambiguous(&self) -> u64
Lifetime ambiguous total, ignoring resets. Monotonic.