pub struct StatsCollector {
pub key_events_processed: u64,
pub key_events_passed: u64,
pub key_events_dropped: u64,
pub per_key_stats: Vec<KeyStats>,
pub per_key_near_miss_stats: Vec<NearMissStats>,
pub overall_bounce_histogram: TimingHistogram,
pub overall_near_miss_histogram: TimingHistogram,
}Expand description
Top-level statistics collector. Owned and managed by the logger thread. Accumulates counts, drop timings, and near-miss timings for all processed events.
Fields§
§key_events_processed: u64Total count of key events processed (passed or dropped).
key_events_passed: u64Total count of key events that passed the filter.
key_events_dropped: u64Total count of key events dropped by the filter.
per_key_stats: Vec<KeyStats>Holds aggregated drop stats per key code. Uses a fixed-size array for O(1) lookup.
per_key_near_miss_stats: Vec<NearMissStats>Holds near-miss stats per key code and value. Indexed by keycode * 3 + value.
overall_bounce_histogram: TimingHistogramOverall histogram for all bounce timings. Aggregated before reporting.
overall_near_miss_histogram: TimingHistogramOverall histogram for all near_miss timings. Aggregated before reporting.
Implementations§
Source§impl StatsCollector
impl StatsCollector
Sourcepub fn with_capacity() -> Self
pub fn with_capacity() -> Self
Creates a new StatsCollector with pre-allocated storage.
Sourcepub fn record_event_info_with_config(
&mut self,
info: &EventInfo,
config: &Config,
)
pub fn record_event_info_with_config( &mut self, info: &EventInfo, config: &Config, )
Updates statistics based on information about a processed event, using the provided configuration. This is the central method for stats accumulation, called by the logger thread.
Sourcepub fn aggregate_histograms(&mut self)
pub fn aggregate_histograms(&mut self)
Aggregates per-key histograms into the overall histograms. Should be called before generating reports.
Sourcepub fn format_stats_human_readable(
&mut self,
config: &Config,
report_type: &str,
writer: impl Write,
) -> Result<()>
pub fn format_stats_human_readable( &mut self, config: &Config, report_type: &str, writer: impl Write, ) -> Result<()>
Formats human-readable statistics summary and writes it to the provided writer. Returns an io::Result to handle potential write errors.
Sourcepub fn print_stats_to_stderr(&mut self, config: &Config, report_type: &str)
pub fn print_stats_to_stderr(&mut self, config: &Config, report_type: &str)
Prints human-readable statistics summary to stderr by calling format_stats_human_readable.
Trait Implementations§
Source§impl Clone for StatsCollector
impl Clone for StatsCollector
Source§fn clone(&self) -> StatsCollector
fn clone(&self) -> StatsCollector
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for StatsCollector
impl Debug for StatsCollector
Auto Trait Implementations§
impl Freeze for StatsCollector
impl RefUnwindSafe for StatsCollector
impl Send for StatsCollector
impl Sync for StatsCollector
impl Unpin for StatsCollector
impl UnsafeUnpin for StatsCollector
impl UnwindSafe for StatsCollector
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
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> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request