diff options
| -rw-r--r-- | src/sync/metrics.rs | 1 | ||||
| -rw-r--r-- | src/sync/mod.rs | 2 | ||||
| -rw-r--r-- | 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 { | |||
| 154 | self.connection_attempts_total | 154 | self.connection_attempts_total |
| 155 | .with_label_values(&[relay, result]) | 155 | .with_label_values(&[relay, result]) |
| 156 | .inc(); | 156 | .inc(); |
| 157 | self.set_relay_connected(relay, success); | ||
| 157 | } | 158 | } |
| 158 | 159 | ||
| 159 | /// Set relay connection status. | 160 | /// 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 { | |||
| 1208 | if is_new { | 1208 | if is_new { |
| 1209 | if let Some(ref metrics) = self.metrics { | 1209 | if let Some(ref metrics) = self.metrics { |
| 1210 | metrics.inc_tracked_count(); | 1210 | metrics.inc_tracked_count(); |
| 1211 | // Initialize connection status to disconnected | ||
| 1212 | metrics.set_relay_connected(&relay_url, false); | ||
| 1211 | } | 1213 | } |
| 1212 | tracing::info!(relay = %relay_url, "Registered new relay for tracking"); | 1214 | tracing::info!(relay = %relay_url, "Registered new relay for tracking"); |
| 1213 | } | 1215 | } |
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() { | |||
| 444 | async fn test_relay_connected_status() { | 444 | async fn test_relay_connected_status() { |
| 445 | let mut harness = MetricsTestHarness::with_sources(1).await; | 445 | let mut harness = MetricsTestHarness::with_sources(1).await; |
| 446 | harness.start_syncing_relay(0).await; | 446 | harness.start_syncing_relay(0).await; |
| 447 | tokio::time::sleep(Duration::from_secs(2)).await; | ||
| 448 | 447 | ||
| 449 | // Clone the URL to avoid borrow issues when stopping source | ||
| 450 | let source_url = harness.source_url(0).to_string(); | 448 | let source_url = harness.source_url(0).to_string(); |
| 451 | 449 | ||
| 452 | // Check connected status | 450 | // Check connected status |
| @@ -454,8 +452,6 @@ async fn test_relay_connected_status() { | |||
| 454 | 452 | ||
| 455 | println!("Checking connection status for {}", source_url); | 453 | println!("Checking connection status for {}", source_url); |
| 456 | 454 | ||
| 457 | // NOTE: This will likely fail until sync metrics are wired up | ||
| 458 | // Test documents the expectation | ||
| 459 | assert_eq!( | 455 | assert_eq!( |
| 460 | metrics.relay_connected(&source_url), | 456 | metrics.relay_connected(&source_url), |
| 461 | Some(true), | 457 | Some(true), |