feat: Prometheus metrics on relay + web bridge, client JSONL export (T5-S1/S3/S4)

WZP-P2-T5-S1: Relay Prometheus /metrics
- RelayMetrics: active_sessions, active_rooms, packets/bytes_forwarded,
  auth_attempts (ok/fail), handshake_duration histogram
- --metrics-port flag spawns HTTP server
- Wired into auth, handshake, session, and packet forwarding paths
- 2 tests

WZP-P2-T5-S3: Web bridge Prometheus /metrics
- WebMetrics: active_connections, frames_bridged (up/down),
  auth_failures, handshake_latency histogram
- Added /metrics route to existing axum app
- Wired into WS connect/disconnect, auth, handshake, send/recv loops
- 2 tests

WZP-P2-T5-S4: Client --metrics-file JSONL
- ClientMetricsSnapshot with all telemetry fields
- MetricsWriter: writes one JSON line per second to file
- snapshot_from_stats() converts JitterStats to snapshot
- --metrics-file <path> flag
- 3 tests

223 tests passing across all crates.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Siavash Sameni
2026-03-28 12:44:57 +04:00
parent 3f813cd510
commit 39f6908478
14 changed files with 645 additions and 12 deletions

View File

@@ -46,6 +46,7 @@ struct CliArgs {
mnemonic: Option<String>,
room: Option<String>,
token: Option<String>,
metrics_file: Option<String>,
}
impl CliArgs {
@@ -86,6 +87,7 @@ fn parse_args() -> CliArgs {
let mut mnemonic = None;
let mut room = None;
let mut token = None;
let mut metrics_file = None;
let mut relay_str = None;
let mut i = 1;
@@ -132,6 +134,14 @@ fn parse_args() -> CliArgs {
i += 1;
token = Some(args.get(i).expect("--token requires a value").to_string());
}
"--metrics-file" => {
i += 1;
metrics_file = Some(
args.get(i)
.expect("--metrics-file requires a path")
.to_string(),
);
}
"--record" => {
i += 1;
record_file = Some(
@@ -174,6 +184,7 @@ fn parse_args() -> CliArgs {
eprintln!(" --mnemonic <words...> Identity seed as BIP39 mnemonic (24 words)");
eprintln!(" --room <name> Room name (hashed for privacy before sending)");
eprintln!(" --token <token> featherChat bearer token for relay auth");
eprintln!(" --metrics-file <path> Write JSONL telemetry to file (1 line/sec)");
eprintln!(" (48kHz mono s16le, play with ffplay -f s16le -ar 48000 -ch_layout mono file.raw)");
eprintln!();
eprintln!("Default relay: 127.0.0.1:4433");
@@ -209,6 +220,7 @@ fn parse_args() -> CliArgs {
mnemonic,
room,
token,
metrics_file,
}
}