From dd403b17e7c74db9443d0891a9de1f0f0f9f89eb Mon Sep 17 00:00:00 2001 From: DanConwayDev Date: Thu, 4 Dec 2025 18:43:49 +0000 Subject: feat(sync): Phase 6 - observability and production readiness - Add SyncMetrics with full Prometheus integration - Track sync gaps via catchup events - Update Grafana dashboard with sync panels - Document all sync configuration options - Update design doc with implementation notes --- src/metrics/mod.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'src/metrics') diff --git a/src/metrics/mod.rs b/src/metrics/mod.rs index 4a4fe57..736414f 100644 --- a/src/metrics/mod.rs +++ b/src/metrics/mod.rs @@ -5,6 +5,7 @@ //! - Git operation metrics (clone, fetch, push) //! - Repository bandwidth tracking (top-N only for cardinality control) //! - Nostr event metrics +//! - Sync metrics (GRASP-02 proactive sync) //! //! # Privacy //! IP addresses are NEVER exposed in metrics. The `ConnectionTracker` maintains @@ -14,6 +15,8 @@ pub mod bandwidth; pub mod connection; +pub use crate::sync::SyncMetrics; + use std::sync::Arc; use std::time::Instant; @@ -46,6 +49,9 @@ struct MetricsInner { /// Repository bandwidth tracking (top-N only) pub bandwidth_tracker: BandwidthTracker, + /// Sync metrics (GRASP-02 proactive sync) + pub sync_metrics: Option, + // === WebSocket Metrics === /// Total WebSocket connections since startup pub websocket_connections_total: Counter, @@ -97,6 +103,11 @@ impl Metrics { } } + /// Returns the sync metrics if registered. + pub fn sync_metrics(&self) -> Option<&crate::sync::SyncMetrics> { + self.inner.sync_metrics.as_ref() + } + /// Returns the connection tracker for WebSocket connection management. pub fn connection_tracker(&self) -> &ConnectionTracker { &self.inner.connection_tracker @@ -248,6 +259,12 @@ impl MetricsInner { // Create bandwidth tracker let bandwidth_tracker = BandwidthTracker::new(®ISTRY); + // Create sync metrics (may fail if already registered in tests) + let sync_metrics = crate::sync::SyncMetrics::register(®ISTRY).ok(); + if sync_metrics.is_some() { + tracing::info!("Sync metrics registered with Prometheus"); + } + // WebSocket metrics let websocket_connections_total = Counter::with_opts( Opts::new( @@ -377,6 +394,7 @@ impl MetricsInner { Self { connection_tracker, bandwidth_tracker, + sync_metrics, websocket_connections_total, websocket_connection_duration, websocket_messages_received, -- cgit v1.2.3