diff options
| author | DanConwayDev <DanConwayDev@protonmail.com> | 2025-12-22 14:23:46 +0000 |
|---|---|---|
| committer | DanConwayDev <DanConwayDev@protonmail.com> | 2025-12-22 14:23:46 +0000 |
| commit | 541f34a207047b26547154e7d631005d456f12fd (patch) | |
| tree | 446cffc4b3bbc32bf61933b5ab41a044a35d6f3b /src/sync/metrics.rs | |
| parent | b10a6cc91dab4c3d83d62fe8cb357c78f2cd4d1e (diff) | |
sync: add req rate-limit detection and cooldown
Diffstat (limited to 'src/sync/metrics.rs')
| -rw-r--r-- | src/sync/metrics.rs | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/src/sync/metrics.rs b/src/sync/metrics.rs index 22c9192..453a79c 100644 --- a/src/sync/metrics.rs +++ b/src/sync/metrics.rs | |||
| @@ -72,7 +72,7 @@ impl SyncMetrics { | |||
| 72 | let relay_status = IntGaugeVec::new( | 72 | let relay_status = IntGaugeVec::new( |
| 73 | Opts::new( | 73 | Opts::new( |
| 74 | "ngit_sync_relay_status", | 74 | "ngit_sync_relay_status", |
| 75 | "Relay health status (1=healthy, 2=degraded, 3=dead)", | 75 | "Relay health status (1=healthy, 2=disconnected, 3=degraded, 4=dead, 5=rate_limited)", |
| 76 | ), | 76 | ), |
| 77 | &["relay"], | 77 | &["relay"], |
| 78 | )?; | 78 | )?; |
| @@ -178,9 +178,11 @@ impl SyncMetrics { | |||
| 178 | /// Record relay health state change. | 178 | /// Record relay health state change. |
| 179 | /// | 179 | /// |
| 180 | /// Maps health states to numeric values for Prometheus: | 180 | /// Maps health states to numeric values for Prometheus: |
| 181 | /// - Healthy = 1 | 181 | /// - Healthy = 1 (connected and stable) |
| 182 | /// - Degraded = 2 | 182 | /// - Disconnected = 2 (not connected, but no issues) |
| 183 | /// - Dead = 3 | 183 | /// - Degraded = 3 (connection problems or unstable after recovery) |
| 184 | /// - Dead = 4 (24h+ of failures) | ||
| 185 | /// - RateLimited = 5 (rate limit cooldown active) | ||
| 184 | /// | 186 | /// |
| 185 | /// # Arguments | 187 | /// # Arguments |
| 186 | /// | 188 | /// |
| @@ -189,8 +191,10 @@ impl SyncMetrics { | |||
| 189 | pub fn record_health_state(&self, relay: &str, state: HealthState) { | 191 | pub fn record_health_state(&self, relay: &str, state: HealthState) { |
| 190 | let state_value = match state { | 192 | let state_value = match state { |
| 191 | HealthState::Healthy => 1, | 193 | HealthState::Healthy => 1, |
| 192 | HealthState::Degraded => 2, | 194 | HealthState::Disconnected => 2, |
| 193 | HealthState::Dead => 3, | 195 | HealthState::Degraded => 3, |
| 196 | HealthState::Dead => 4, | ||
| 197 | HealthState::RateLimited => 5, | ||
| 194 | }; | 198 | }; |
| 195 | self.relay_status | 199 | self.relay_status |
| 196 | .with_label_values(&[relay]) | 200 | .with_label_values(&[relay]) |