Skip to content

Commit de14c90

Browse files
davidv1992rnijveld
authored andcommitted
[Management] Surface RTT and offset in time source logs.
1 parent dd2b56c commit de14c90

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

nts-pool-management/src/routes/management.rs

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,14 +89,33 @@ fn extract_keyexchange_status(ke: &Value) -> Option<String> {
8989
.or_else(|| {
9090
ke.get("status")
9191
.and_then(|ke_status| ke_status.as_str())
92-
.map(|ke_status| ke_status.to_owned())
92+
.map(|ke_status| {
93+
ke.get("exchange_duration")
94+
.and_then(|v| v.as_f64())
95+
.map(|v| format!("{} (duration: {:.1}ms)", ke_status, v * 1000.0))
96+
.unwrap_or_else(|| ke_status.to_owned())
97+
})
9398
})
9499
}
95100

96101
fn extract_ntp_status(ntp: &Value) -> Option<String> {
97102
ntp.get("status")
98103
.and_then(|ntp_status| ntp_status.as_str())
99-
.map(|ntp_status| ntp_status.to_owned())
104+
.map(|ntp_status| {
105+
let rtt = ntp.get("roundtrip_duration").and_then(|v| v.as_f64());
106+
let offset = ntp.get("offset").and_then(|v| v.as_f64());
107+
108+
match (rtt, offset) {
109+
(Some(rtt), Some(offset)) => format!(
110+
"{} (RTT: {:.1}ms, offset: {:.1}ms)",
111+
ntp_status,
112+
rtt * 1000.0,
113+
offset * 1000.0
114+
),
115+
(Some(rtt), None) => format!("{} (RTT: {:.1}ms)", ntp_status, rtt * 1000.0),
116+
_ => ntp_status.to_owned(),
117+
}
118+
})
100119
}
101120

102121
pub async fn time_source_info(

0 commit comments

Comments
 (0)