hyperhive/hive-c0re/src/lib.rs
atlas 419c9659a3 feat(#2007): export per-agent container cpu/mem/disk via otel
hive-c0re already samples each agent container's cgroup load for the
dashboard (stats/container_stats.rs); this rides those gauges out to the
configured OTLP endpoint, reusing the existing services.hyperhive.otel
config (endpoint + auth header) — no new toggle.

- New stats/otel_metrics.rs: exports via the OpenTelemetry Rust SDK (same
  crates as hive-metric) with the semconv container.* metric names +
  container.name attribute so off-the-shelf OTel/Grafana dashboards work,
  plus the hive agent label. container.cpu.time (counter, s, from cumulative
  cpu.stat usage_usec), container.memory.usage, container.memory.usage.limit;
  memory peak / on-disk storage / instantaneous cpu percent stay hyperhive.*
  custom (no semconv equivalent). Observable instruments read a shared
  snapshot an async task refreshes (gather() is async; SDK callbacks sync).
- container_stats: expose cpu_time_usec (cumulative) on ContainerResource.
- The OTLP auth header is loaded onto hive-c0re's own unit via systemd
  LoadCredential and read from $CREDENTIALS_DIRECTORY/otel-headers.
- docs/observability.md documents the host-emitted semconv metrics.

Host-side export, so it covers containers even when their agent is idle.
2026-07-15 22:51:31 +02:00

54 lines
1.9 KiB
Rust

//! `hive-c0re` library — the coordinator daemon's module surface
//! (coordinator, broker, axum dashboard, admin/manager/agent unix
//! sockets, background sweepers). Consumed by the `hive-c0re` daemon
//! binary (`src/main.rs`).
//!
//! The operator CLI lives in the **standalone `hivectl` crate**, which
//! talks to the daemon over the host admin socket (`hive-host-sock` wire
//! types) rather than linking this crate — so `hive-c0re` is daemon-only,
//! not a library shared with a CLI.
//!
//! Every module is re-exported `pub` so anything in the crate is
//! addressable from the daemon binary; the lib doesn't have a curated
//! surface beyond "this is where the modules live".
//!
//! Cohesive clusters live in directory submodules (`stores`, `stats`,
//! `agent_config`, `workers`); each of their children is re-exported
//! at the crate root so pre-existing `crate::broker::…` /
//! `hive_c0re::broker::…` paths keep compiling unchanged.
pub mod actions;
pub mod agent_config;
pub mod container_view;
pub mod coordinator;
pub mod dashboard;
pub mod dashboard_events;
pub mod forge;
pub mod gateway_nginx;
pub mod job_queue;
pub mod lifecycle;
pub mod loose_ends;
pub mod matrix;
pub mod meta;
pub mod migrate;
pub mod paths;
pub mod priv_client;
pub mod questions;
pub mod server;
pub mod socket_server;
pub mod stats;
pub mod stores;
pub mod webhook_secret;
pub mod workers;
// Root re-exports: keep every pre-grouping `crate::<module>` /
// `hive_c0re::<module>` path compiling without touching consumers.
pub use agent_config::{capabilities, limits, tool_groups, topology};
pub use stats::{container_stats, hive_stats, host_stats, otel_metrics, sweep_health, warnings};
pub use stores::{
approvals, audit_log, broker, build_logs, db, operator_questions, power, scheduled_prompts,
};
pub use workers::{
agent_sockets, auto_update, crash_watch, knowledge, mcp_sockets, reminder_scheduler,
scheduled_prompts_worker,
};