diff options
| author | DanConwayDev <DanConwayDev@protonmail.com> | 2025-12-11 16:53:03 +0000 |
|---|---|---|
| committer | DanConwayDev <DanConwayDev@protonmail.com> | 2025-12-11 16:53:03 +0000 |
| commit | 2a9160836bb87fdea3ae891563b0169c68d1c2ab (patch) | |
| tree | 583c890687beaf7f380fc0be131bdf17485f06fa /src/sync/metrics.rs | |
| parent | 52489d3b1a7d79e164b4cc901b53fd06c05ce1b1 (diff) | |
fix: resolve all fmt and clippy warnings
Main lib (src/):
- Add #[allow(dead_code)] for build_info field (stored to prevent Prometheus unregistration)
- Add #[allow(dead_code)] for first_seen field (reserved for future rate limiting)
- Replace .or_insert_with(RelaySyncNeeds::default) with .or_default()
- Replace manual div_ceil implementations with .div_ceil(100)
Test code (tests/):
- Replace .expect(&format!(...)) with .unwrap_or_else(|_| panic!(...))
- Remove needless borrows in fetch_metrics() calls
- Add #[allow(dead_code)] and #[allow(unused_imports)] to test helpers module
grasp-audit:
- Apply cargo fmt to fix formatting
Diffstat (limited to 'src/sync/metrics.rs')
| -rw-r--r-- | src/sync/metrics.rs | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/sync/metrics.rs b/src/sync/metrics.rs index 411ff63..d917dc0 100644 --- a/src/sync/metrics.rs +++ b/src/sync/metrics.rs | |||
| @@ -207,7 +207,9 @@ impl SyncMetrics { | |||
| 207 | HealthState::Degraded => 2, | 207 | HealthState::Degraded => 2, |
| 208 | HealthState::Dead => 3, | 208 | HealthState::Dead => 3, |
| 209 | }; | 209 | }; |
| 210 | self.relay_status.with_label_values(&[relay]).set(state_value); | 210 | self.relay_status |
| 211 | .with_label_values(&[relay]) | ||
| 212 | .set(state_value); | ||
| 211 | } | 213 | } |
| 212 | 214 | ||
| 213 | /// Record relay failure count. | 215 | /// Record relay failure count. |
| @@ -259,9 +261,7 @@ impl SyncMetrics { | |||
| 259 | /// * `source` - The event source type (see [`record_event`](Self::record_event)) | 261 | /// * `source` - The event source type (see [`record_event`](Self::record_event)) |
| 260 | /// * `count` - Number of events to record | 262 | /// * `count` - Number of events to record |
| 261 | pub fn record_events(&self, source: &str, count: u64) { | 263 | pub fn record_events(&self, source: &str, count: u64) { |
| 262 | self.events_total | 264 | self.events_total.with_label_values(&[source]).inc_by(count); |
| 263 | .with_label_values(&[source]) | ||
| 264 | .inc_by(count); | ||
| 265 | } | 265 | } |
| 266 | 266 | ||
| 267 | /// Record a gap event filled during catchup. | 267 | /// Record a gap event filled during catchup. |
| @@ -451,4 +451,4 @@ mod tests { | |||
| 451 | let metrics2 = SyncMetrics::register(®istry); | 451 | let metrics2 = SyncMetrics::register(®istry); |
| 452 | assert!(metrics2.is_err()); | 452 | assert!(metrics2.is_err()); |
| 453 | } | 453 | } |
| 454 | } \ No newline at end of file | 454 | } |