feat(client): report relay RTT diagnostics
Expose the active QUIC connection RTT in shared client diagnostics and in the Windows client status line. This gives operators a live relay-path latency signal without pretending to measure end-to-end gateway or LAN latency. The new diagnostics field defaults to unknown when older JSON snapshots omit it, so consumers can read pre-change snapshots without special migration code. The user-facing diagnostics now print Relay RTT only when the client has an active QUIC measurement. Test Plan: - cargo fmt --check - git diff --check - cargo test --workspace - cargo clippy --workspace --all-targets -- -D warnings Refs: PLAN.md logging and diagnostics section
This commit is contained in:
@@ -458,12 +458,13 @@ async fn print_and_report_client_diagnostics(
|
||||
fn format_client_diagnostics(diagnostics: &ClientDiagnostics) -> String {
|
||||
let stats = diagnostics.stats();
|
||||
format!(
|
||||
"client diagnostics: relay reachable {} gateway connected {} route pinned {}; QUIC datagrams {} max {}; TAP found {} MAC {} MTU {} IP {}; frames tx {} rx {} broadcast tx {} rx {} datagrams tx {} rx {} drops {} malformed {}",
|
||||
"client diagnostics: relay reachable {} gateway connected {} route pinned {}; QUIC datagrams {} max {} relay RTT {}; TAP found {} MAC {} MTU {} IP {}; frames tx {} rx {} broadcast tx {} rx {} datagrams tx {} rx {} drops {} malformed {}",
|
||||
yes_no(diagnostics.relay().reachable()),
|
||||
yes_no(diagnostics.relay().gateway_connected()),
|
||||
yes_no(diagnostics.relay().route_pinned()),
|
||||
yes_no(diagnostics.quic().datagram_supported()),
|
||||
optional_label(diagnostics.quic().max_datagram_size()),
|
||||
optional_millis_label(diagnostics.quic().relay_rtt_ms()),
|
||||
yes_no(diagnostics.tap().adapter_found()),
|
||||
optional_label(diagnostics.tap().mac()),
|
||||
optional_label(diagnostics.tap().mtu()),
|
||||
@@ -487,6 +488,10 @@ fn optional_label<T: std::fmt::Display>(value: Option<T>) -> String {
|
||||
value.map_or_else(|| "unknown".to_string(), |value| value.to_string())
|
||||
}
|
||||
|
||||
fn optional_millis_label(value: Option<u64>) -> String {
|
||||
value.map_or_else(|| "unknown".to_string(), |value| format!("{value} ms"))
|
||||
}
|
||||
|
||||
fn format_user_diagnostic(diagnostic: &UserDiagnostic) -> String {
|
||||
match diagnostic.level() {
|
||||
UserDiagnosticLevel::Info => diagnostic.message().to_owned(),
|
||||
@@ -875,7 +880,7 @@ mod tests {
|
||||
fn formats_client_diagnostics_status_line() {
|
||||
let diagnostics = ClientDiagnostics::new(
|
||||
RelayDiagnostics::new(true, true, true),
|
||||
QuicDiagnostics::new(true, Some(1400)),
|
||||
QuicDiagnostics::new(true, Some(1400)).with_relay_rtt_ms(Some(23)),
|
||||
TapDiagnostics::new(
|
||||
true,
|
||||
Some(mac(1)),
|
||||
@@ -887,7 +892,7 @@ mod tests {
|
||||
|
||||
assert_eq!(
|
||||
format_client_diagnostics(&diagnostics),
|
||||
"client diagnostics: relay reachable yes gateway connected yes route pinned yes; QUIC datagrams yes max 1400; TAP found yes MAC 02:00:00:00:00:01 MTU 1200 IP 10.73.42.51; frames tx 1 rx 2 broadcast tx 7 rx 8 datagrams tx 3 rx 4 drops 5 malformed 6"
|
||||
"client diagnostics: relay reachable yes gateway connected yes route pinned yes; QUIC datagrams yes max 1400 relay RTT 23 ms; TAP found yes MAC 02:00:00:00:00:01 MTU 1200 IP 10.73.42.51; frames tx 1 rx 2 broadcast tx 7 rx 8 datagrams tx 3 rx 4 drops 5 malformed 6"
|
||||
);
|
||||
}
|
||||
|
||||
@@ -902,7 +907,7 @@ mod tests {
|
||||
|
||||
assert_eq!(
|
||||
format_client_diagnostics(&diagnostics),
|
||||
"client diagnostics: relay reachable yes gateway connected no route pinned no; QUIC datagrams no max unknown; TAP found no MAC unknown MTU unknown IP unknown; frames tx 0 rx 0 broadcast tx 0 rx 0 datagrams tx 0 rx 0 drops 0 malformed 0"
|
||||
"client diagnostics: relay reachable yes gateway connected no route pinned no; QUIC datagrams no max unknown relay RTT unknown; TAP found no MAC unknown MTU unknown IP unknown; frames tx 0 rx 0 broadcast tx 0 rx 0 datagrams tx 0 rx 0 drops 0 malformed 0"
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user