* worker.rs (1271 lines, 1120 of them tests) is 149 lines; the supervisor tests are worker/tests.rs (shared fixtures) and
worker/tests/{deadlines,handshake,generation,restart,lifecycle,reasoning}.rs. The test names are unchanged; their path
gains the topic module (worker::tests::restart::..., see scripts/dev/test-outcomes.py compare: 23 MOVED, outcomes equal).
* vision.rs 402 -> 120 lines (tests are vision/tests.rs, same test ids); prometheus.rs 441 -> 50 (the series table is
prometheus/series.rs); service_install.rs 436 -> 30 (the unix half is service_install/unix.rs and unix/tests.rs, same ids).
* config: Config::load_with_path (430 lines in one function) hands its limits, engine-worker and MCP sections to
config/methods/load_sections.rs; the same checks run in the same order with the same messages.
* mcp, request_log, vision, worker, config: impl_*/note_*/check_* file names are now hub.rs, server.rs, stdio_transport.rs,
http_transport.rs, parse_config.rs, obs_handle.rs, engine_counters.rs, encoder.rs, cleanup.rs, generation_result.rs, ...
Public paths are unchanged (the modules re-export with glob as before).
Architecture gate: five oversize entries leave the baseline (worker.rs, vision.rs, prometheus.rs, service_install.rs,
config impl_config_2_2.rs); no number rose.
51 lines
1.6 KiB
Rust
51 lines
1.6 KiB
Rust
//! `GET /metrics?format=prometheus` (or an `Accept` that asks for `text/plain` / OpenMetrics): the same document as the JSON
|
|
//! `/metrics`, as Prometheus text exposition. A figure the document leaves `null` or does not have is not exposed (Prometheus
|
|
//! has no null; a missing series is the honest answer for "not measured"). Counters carry the `_total` suffix and
|
|
//! count since the control plane started; everything else is a gauge sampled when the endpoint is read.
|
|
//!
|
|
//! The table below is the contract: metric name, type, help, where it comes from in the JSON document, and a scale.
|
|
|
|
use std::fmt::Write;
|
|
|
|
use serde_json::Value;
|
|
|
|
pub const CONTENT_TYPE: &str = "text/plain; version=0.0.4; charset=utf-8";
|
|
|
|
#[derive(Clone, Copy, PartialEq, Eq)]
|
|
enum Kind {
|
|
Counter,
|
|
Gauge,
|
|
}
|
|
|
|
struct Series {
|
|
name: &'static str,
|
|
kind: Kind,
|
|
help: &'static str,
|
|
/// JSON pointer into the `/metrics` document.
|
|
from: &'static str,
|
|
scale: f64,
|
|
/// A fixed label, `name="value"` (several series of one metric differ only by it).
|
|
label: Option<(&'static str, &'static str)>,
|
|
}
|
|
|
|
/// The phase the engine reports, as a one-hot gauge (`idle`, `prefill`, `decode`).
|
|
const PHASES: [&str; 3] = ["idle", "prefill", "decode"];
|
|
|
|
/// NVML `nvmlClocksThrottleReason*` bits that cost speed.
|
|
const THROTTLE_REASONS: [(u64, &str); 5] = [
|
|
(0x4, "sw_power_cap"),
|
|
(0x8, "hw_slowdown"),
|
|
(0x20, "sw_thermal"),
|
|
(0x40, "hw_thermal"),
|
|
(0x80, "hw_power_brake"),
|
|
];
|
|
|
|
#[cfg(test)]
|
|
mod tests;
|
|
|
|
mod series;
|
|
use series::SERIES;
|
|
mod counter;
|
|
#[allow(unused_imports)]
|
|
pub use counter::*;
|