MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / append_histogram

Function append_histogram

nodedb/src/control/security/observability.rs:278–288  ·  view source on GitHub ↗
(out: &mut String, name: &str, buckets: &[AtomicU64; 7])

Source from the content-addressed store, hash-verified

276}
277
278fn append_histogram(out: &mut String, name: &str, buckets: &[AtomicU64; 7]) {
279 let boundaries = ["0.001", "0.005", "0.01", "0.05", "0.1", "0.5", "+Inf"];
280 let mut cumulative = 0u64;
281 for (i, boundary) in boundaries.iter().enumerate() {
282 cumulative += buckets[i].load(Ordering::Relaxed);
283 out.push_str(&format!(
284 "{name}_bucket{{le=\"{boundary}\"}} {cumulative}\n"
285 ));
286 }
287 out.push_str(&format!("{name}_count {cumulative}\n"));
288}
289
290#[cfg(test)]
291mod tests {

Callers 1

to_prometheusMethod · 0.85

Calls 2

iterMethod · 0.45
loadMethod · 0.45

Tested by

no test coverage detected