From 02a90c109d4d08c6a54184f821c100f4eba92545 Mon Sep 17 00:00:00 2001 From: DanConwayDev Date: Fri, 19 Dec 2025 15:53:48 +0000 Subject: Simplify sync metrics to track only newly saved events Replace broken event counting that occurred before duplicate/policy checks with accurate tracking of events that are new, accepted, and saved. Changes: - Added ProcessResult enum to track event processing outcomes - Modified process_event_static() to return ProcessResult - Replaced events_total (with source labels) with events_synced_total - Removed gap_events_total and event_source module - Removed eose_received flag (EOSE is per-subscription, not suitable) - Updated all tests to use new simplified API The new ngit_sync_events_synced_total metric only counts events that: 1. Are new (not duplicates) 2. Pass write policy validation 3. Are successfully saved to database All 165 tests pass (124 lib + 41 integration) --- tests/sync/metrics.rs | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'tests/sync') diff --git a/tests/sync/metrics.rs b/tests/sync/metrics.rs index 16c95c9..987b83a 100644 --- a/tests/sync/metrics.rs +++ b/tests/sync/metrics.rs @@ -312,13 +312,11 @@ async fn test_startup_sync_event_count() { // 11. Check sync metrics let tracked = metrics.gauge("ngit_sync_relays_tracked_total", &[]); let connected = metrics.gauge("ngit_sync_relays_connected_total", &[]); - let startup_events = metrics.events_total("startup"); - let live_events = metrics.events_total("live"); + let events_synced = metrics.events_synced_total(); println!("Relays tracked: {:?}", tracked); println!("Relays connected: {:?}", connected); - println!("Startup events synced: {:?}", startup_events); - println!("Live events synced: {:?}", live_events); + println!("Events synced total: {:?}", events_synced); // 12. Verify patches actually synced (functional check) let filter = Filter::new() @@ -447,10 +445,10 @@ async fn test_live_sync_event_count() { tokio::time::sleep(Duration::from_secs(4)).await; let metrics = harness.get_metrics().await.unwrap(); - let live_count = metrics.events_total("live"); - println!("Live events synced: {:?}", live_count); + let synced_count = metrics.events_synced_total(); + println!("Events synced total: {:?}", synced_count); - assert_eq!(live_count, Some(2), "Should have 2 live events"); + assert_eq!(synced_count, Some(2), "Should have 2 synced events"); harness.stop_all().await; } -- cgit v1.2.3