Watch
0
0
Fork
You've already forked hyperhive
0

hive-c0re: the container stats comments and docs name the OTEL exporter as the consumer, not the removed tab

This commit is contained in:
iris 2026-10-15 00:06:47 +02:00 • committed by mara
commit c875223db7
5 changed files with 16 additions and 15 deletions

View file

@ -1,6 +1,6 @@
//! Live per-agent-container resource load (CPU + memory, plus the slow
//! disk sample from hive-priv in [`disk_sampler_loop`]) for the
//! dashboard. Reads cgroup v2 stat files for each running agent
//! disk sample from hive-priv in [`disk_sampler_loop`]) for the OTEL
//! exporter. Reads cgroup v2 stat files for each running agent
//! machine directly — same privsep-clean posture as the turn-stats
//! sqlite reads (`cpu.stat` / `memory.*` are world-readable; no
//! `hive-priv` needed). Runs host-side in hive-c0re, where
@ -31,8 +31,8 @@ use utoipa::ToSchema;
use crate::coordinator::Coordinator;
/// Sampling interval for the two CPU reads. Short enough to keep the
/// endpoint snappy, long enough that the delta isn't dominated by read
/// Sampling interval for the two CPU reads. Short enough to keep a sample
/// quick, long enough that the delta isn't dominated by read
/// jitter.
const CPU_SAMPLE: Duration = Duration::from_millis(200);
@ -72,8 +72,8 @@ pub struct ContainerResource {
const DISK_SAMPLE_INTERVAL: Duration = Duration::from_mins(30);
/// Last per-agent disk measurement, keyed by agent name; `None` is a failed
/// one. Written by [`disk_sampler_loop`], read by [`gather`] so the hot
/// poll never measures.
/// one. Written by [`disk_sampler_loop`], read by [`gather`], so a sample
/// never measures.
fn disk_cache() -> &'static RwLock<HashMap<String, Option<u64>>> {
static CACHE: OnceLock<RwLock<HashMap<String, Option<u64>>>> = OnceLock::new();
CACHE.get_or_init(|| RwLock::new(HashMap::new()))
@ -100,7 +100,7 @@ fn disk_reading(name: &hive_types::Ident, measured: anyhow::Result<u64>) -> Opti
/// Background loop: every [`DISK_SAMPLE_INTERVAL`], remeasure disk usage
/// for every kept-state agent and refresh [`disk_cache`]. The first pass
/// runs immediately so the dashboard shows disk shortly after boot.
/// runs immediately so the exporter has disk shortly after boot.
/// Runs forever; spawn once at hive-c0re startup via [`spawn_disk_sampler`].
pub async fn disk_sampler_loop() {
loop {