diff options
| author | DanConwayDev <DanConwayDev@protonmail.com> | 2025-12-19 15:53:48 +0000 |
|---|---|---|
| committer | DanConwayDev <DanConwayDev@protonmail.com> | 2025-12-19 15:59:23 +0000 |
| commit | 02a90c109d4d08c6a54184f821c100f4eba92545 (patch) | |
| tree | a8c07978d5a7c58e2776cf057cc89e1233de1eee /tests/sync | |
| parent | 565715adf14cafd0f0155d553f583581334a8dac (diff) | |
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)
Diffstat (limited to 'tests/sync')
| -rw-r--r-- | tests/sync/metrics.rs | 12 |
1 files changed, 5 insertions, 7 deletions
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() { | |||
| 312 | // 11. Check sync metrics | 312 | // 11. Check sync metrics |
| 313 | let tracked = metrics.gauge("ngit_sync_relays_tracked_total", &[]); | 313 | let tracked = metrics.gauge("ngit_sync_relays_tracked_total", &[]); |
| 314 | let connected = metrics.gauge("ngit_sync_relays_connected_total", &[]); | 314 | let connected = metrics.gauge("ngit_sync_relays_connected_total", &[]); |
| 315 | let startup_events = metrics.events_total("startup"); | 315 | let events_synced = metrics.events_synced_total(); |
| 316 | let live_events = metrics.events_total("live"); | ||
| 317 | 316 | ||
| 318 | println!("Relays tracked: {:?}", tracked); | 317 | println!("Relays tracked: {:?}", tracked); |
| 319 | println!("Relays connected: {:?}", connected); | 318 | println!("Relays connected: {:?}", connected); |
| 320 | println!("Startup events synced: {:?}", startup_events); | 319 | println!("Events synced total: {:?}", events_synced); |
| 321 | println!("Live events synced: {:?}", live_events); | ||
| 322 | 320 | ||
| 323 | // 12. Verify patches actually synced (functional check) | 321 | // 12. Verify patches actually synced (functional check) |
| 324 | let filter = Filter::new() | 322 | let filter = Filter::new() |
| @@ -447,10 +445,10 @@ async fn test_live_sync_event_count() { | |||
| 447 | tokio::time::sleep(Duration::from_secs(4)).await; | 445 | tokio::time::sleep(Duration::from_secs(4)).await; |
| 448 | let metrics = harness.get_metrics().await.unwrap(); | 446 | let metrics = harness.get_metrics().await.unwrap(); |
| 449 | 447 | ||
| 450 | let live_count = metrics.events_total("live"); | 448 | let synced_count = metrics.events_synced_total(); |
| 451 | println!("Live events synced: {:?}", live_count); | 449 | println!("Events synced total: {:?}", synced_count); |
| 452 | 450 | ||
| 453 | assert_eq!(live_count, Some(2), "Should have 2 live events"); | 451 | assert_eq!(synced_count, Some(2), "Should have 2 synced events"); |
| 454 | 452 | ||
| 455 | harness.stop_all().await; | 453 | harness.stop_all().await; |
| 456 | } | 454 | } |