From c82684092c7b4f81e49833b0888500fcb9851218 Mon Sep 17 00:00:00 2001 From: DanConwayDev Date: Thu, 11 Dec 2025 11:19:38 +0000 Subject: fix(sync): improve metrics recording and connection failure detection Changes: - Fix connection attempt metrics: record success/failure based on actual connection result instead of pre-emptively recording failure - Add health tracker integration on connection failure: call record_failure() and record_health_state() in error path - Add connection verification in relay_connection.rs: wait 500ms after connect() then verify is_connected() to detect silent failures - Add configurable disconnect check interval via NGIT_SYNC_DISCONNECT_CHECK_INTERVAL_SECS env var - Update TestRelay with fast test settings: startup_delay=0, jitter=0, disconnect_check_interval=1s - Add debug output to metrics tests for investigation Note: Tests may still fail due to 5-second base backoff in health tracker. A follow-up task will add NGIT_SYNC_BASE_BACKOFF_SECS config parameter to allow faster test cycles. Related: metrics-wiring-plan.md Tasks 1 & 2 --- src/config.rs | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/config.rs') diff --git a/src/config.rs b/src/config.rs index 69a160a..5e74471 100644 --- a/src/config.rs +++ b/src/config.rs @@ -109,6 +109,11 @@ pub struct Config { /// Set to 0 to disable jitter (useful for testing) #[arg(long, env = "NGIT_SYNC_STARTUP_JITTER_MS", default_value_t = 10_000)] pub sync_startup_jitter_ms: u64, + + /// Interval in seconds for checking disconnected relays and attempting reconnection (default: 60) + /// Set to lower value for faster reconnection testing + #[arg(long, env = "NGIT_SYNC_DISCONNECT_CHECK_INTERVAL_SECS", default_value_t = 60)] + pub sync_disconnect_check_interval_secs: u64, } impl Config { @@ -170,6 +175,7 @@ impl Config { sync_reconnect_delay_secs: 10, sync_reconnect_lookback_days: 3, sync_startup_jitter_ms: 10_000, + sync_disconnect_check_interval_secs: 60, } } } -- cgit v1.2.3