From 11a656fa96d6f60e2d8e8fd31657e24d6cc7cf21 Mon Sep 17 00:00:00 2001 From: DanConwayDev Date: Thu, 18 Dec 2025 12:41:19 +0000 Subject: sync: fix sync connection --- src/sync/metrics.rs | 1 + src/sync/mod.rs | 2 ++ tests/sync/metrics.rs | 4 ---- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/sync/metrics.rs b/src/sync/metrics.rs index d917dc0..c3bebfc 100644 --- a/src/sync/metrics.rs +++ b/src/sync/metrics.rs @@ -154,6 +154,7 @@ impl SyncMetrics { self.connection_attempts_total .with_label_values(&[relay, result]) .inc(); + self.set_relay_connected(relay, success); } /// Set relay connection status. diff --git a/src/sync/mod.rs b/src/sync/mod.rs index 5bea701..c3c598a 100644 --- a/src/sync/mod.rs +++ b/src/sync/mod.rs @@ -1208,6 +1208,8 @@ impl SyncManager { if is_new { if let Some(ref metrics) = self.metrics { metrics.inc_tracked_count(); + // Initialize connection status to disconnected + metrics.set_relay_connected(&relay_url, false); } tracing::info!(relay = %relay_url, "Registered new relay for tracking"); } diff --git a/tests/sync/metrics.rs b/tests/sync/metrics.rs index 14e1dfd..f1f19d0 100644 --- a/tests/sync/metrics.rs +++ b/tests/sync/metrics.rs @@ -444,9 +444,7 @@ async fn test_live_sync_event_count() { async fn test_relay_connected_status() { let mut harness = MetricsTestHarness::with_sources(1).await; harness.start_syncing_relay(0).await; - tokio::time::sleep(Duration::from_secs(2)).await; - // Clone the URL to avoid borrow issues when stopping source let source_url = harness.source_url(0).to_string(); // Check connected status @@ -454,8 +452,6 @@ async fn test_relay_connected_status() { println!("Checking connection status for {}", source_url); - // NOTE: This will likely fail until sync metrics are wired up - // Test documents the expectation assert_eq!( metrics.relay_connected(&source_url), Some(true), -- cgit v1.2.3