Log dropped CSV rows in TrafficLogger instead of silent discard

log_row() previously swallowed TrySendError::Full and Disconnected with
no diagnostic, so a slow writer thread or a dead writer thread (e.g.
after a failed date-rotation reopen) silently truncated the training
CSV with no visible trace. Mirrors the existing SuricataEngine::inject()
channel-full logging pattern.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0138PxtKH73hqxv7h1oaoSdS
This commit is contained in:
Claude 2026-07-02 05:16:06 +00:00
parent 48f1747de3
commit d8de89e930
No known key found for this signature in database
2 changed files with 12 additions and 2 deletions

View File

@ -204,8 +204,12 @@ impl TrafficLogger {
fn log_row(&self, record: Vec<String>) {
match self.sender.try_send(record) {
Ok(_) => {}
Err(TrySendError::Full(_)) => {}
Err(TrySendError::Disconnected(_)) => {}
Err(TrySendError::Full(_)) => {
log!(MLLog::TrafficLogChannelFull);
}
Err(TrySendError::Disconnected(_)) => {
log!(MLLog::TrafficLogChannelDisconnected);
}
}
}
}

View File

@ -78,6 +78,12 @@ loggable! {
#[error("CSV rotated to: {path}")]
TrafficLogRotated { path: String } => tracing::Level::INFO,
#[error("Traffic log channel full; dropping CSV row (writer thread falling behind)")]
TrafficLogChannelFull => tracing::Level::WARN,
#[error("Traffic log channel disconnected; CSV recording has stopped")]
TrafficLogChannelDisconnected => tracing::Level::ERROR,
#[error("Timing [{src}]: feature={feature_ms}ms buffer={buffer_ms}ms tensor={tensor_ms}ms onnx={onnx_ms}ms")]
InferenceTiming { src: String, feature_ms: u64, buffer_ms: u64, tensor_ms: u64, onnx_ms: u64 } => tracing::Level::DEBUG,