Add `secs` fractional CPU-seconds to the maintenance counter for `db_name`. Converts to integer microseconds (rounded) to avoid `AtomicF64` complexity. Negative or non-finite inputs are clamped to zero so accidental underflow in upstream timing arithmetic cannot subtract from the cumulative counter.
(&self, db_name: &str, secs: f64)
| 136 | /// Negative or non-finite inputs are clamped to zero so accidental underflow |
| 137 | /// in upstream timing arithmetic cannot subtract from the cumulative counter. |
| 138 | pub fn add_maintenance_cpu_secs(&self, db_name: &str, secs: f64) { |
| 139 | let us = if secs.is_finite() && secs > 0.0 { |
| 140 | (secs * 1_000_000.0).round() as u64 |
| 141 | } else { |
| 142 | 0 |
| 143 | }; |
| 144 | if us == 0 { |
| 145 | return; |
| 146 | } |
| 147 | self.get_or_create(db_name) |
| 148 | .maintenance_cpu_seconds_total |
| 149 | .fetch_add(us, Ordering::Relaxed); |
| 150 | } |
| 151 | |
| 152 | /// Render all registered databases as Prometheus text format 0.0.4. |
| 153 | /// |
nothing calls this directly
no test coverage detected