refactor(stats): make late-reply sampling explicit
The TUI suppressed late-reply timing by rebuilding the event with sent_at, rtt, server_timing, one_way and received_stats erased. That leaked stats policy into event construction and, as a side effect, reclassified a matched late reply as an untracked late reply. StatsConfig now carries an explicit LateReplyMode. Measure keeps today's behavior for every existing caller. CountOnly keeps the reply a late unique reply and keeps packet, byte and late counters updating, while suppressing timing, one-way, server-processing and IPDV contributions and reporting contributed_sample == false. Cumulative and rolling snapshots share the policy. Genuinely untracked late replies stay untracked in both modes. The TUI selects CountOnly and passes the original event straight to the collector.
This commit is contained in:
1 parent
90c04b6569
commit
e0dec9ac5f
5 files changed
+223
-49
No files matched your search
@@ -1,6 +1,8 @@
|
||||
use std::{collections::VecDeque, time::Duration};
|
||||
|
||||
use crate::{core::CoreStats, normalization::StatsEvent, SampleMode, Snapshot, StatsConfig};
|
||||
use crate::{
|
||||
core::CoreStats, normalization::StatsEvent, LateReplyMode, SampleMode, Snapshot, StatsConfig,
|
||||
};
|
||||
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub(crate) struct RollingEvents {
|
||||
@@ -8,6 +10,7 @@ pub(crate) struct RollingEvents {
|
||||
time_limit: Option<Duration>,
|
||||
count_events: Option<VecDeque<StatsEvent>>,
|
||||
time_events: Option<VecDeque<StatsEvent>>,
|
||||
late_replies: LateReplyMode,
|
||||
}
|
||||
|
||||
impl RollingEvents {
|
||||
@@ -17,6 +20,7 @@ impl RollingEvents {
|
||||
time_limit: config.rolling_time,
|
||||
count_events: config.rolling_count.map(|_| VecDeque::new()),
|
||||
time_events: config.rolling_time.map(|_| VecDeque::new()),
|
||||
late_replies: config.late_replies,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,16 +44,22 @@ impl RollingEvents {
|
||||
}
|
||||
|
||||
pub(crate) fn count_snapshot(&self) -> Option<Snapshot> {
|
||||
self.count_events.as_ref().map(snapshot_window)
|
||||
self.count_events
|
||||
.as_ref()
|
||||
.map(|events| snapshot_window(events, self.late_replies))
|
||||
}
|
||||
|
||||
pub(crate) fn time_snapshot(&self) -> Option<Snapshot> {
|
||||
self.time_events.as_ref().map(snapshot_window)
|
||||
self.time_events
|
||||
.as_ref()
|
||||
.map(|events| snapshot_window(events, self.late_replies))
|
||||
}
|
||||
}
|
||||
|
||||
fn snapshot_window(events: &VecDeque<StatsEvent>) -> Snapshot {
|
||||
let mut core = CoreStats::new(SampleMode::RunningOnly);
|
||||
/// Recompute a window snapshot under the same normalized semantics as the
|
||||
/// cumulative collector, including its late-reply measurement policy.
|
||||
fn snapshot_window(events: &VecDeque<StatsEvent>, late_replies: LateReplyMode) -> Snapshot {
|
||||
let mut core = CoreStats::new(SampleMode::RunningOnly, late_replies);
|
||||
for event in events {
|
||||
core.apply(event.clone());
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user