# observability Metrics, health, logging. Generated by `make records` from the decisions whose `topic` (or `also`) is this one; edit the decisions, not this page. ## Current ### Metrics and logs - **Concurrency waiting reasons name the limit and value** (D91): A waiting reason names the reached concurrency limit and its value. `schedr_tasks_waiting` labels these waits by the limit’s name. - **The UI shows watcher hosts and switched-off sensors** (D343): The Workers page shows each host’s code hash, wait steps, threads, memory and losses; the metrics give totals over the hosts (`worker_watcher_hosts_lost` by code). The DAG page lists switched-off sensors with switch-on; the DAGs list shows their count. - **No OpenTelemetry** (D386): schedr exposes Prometheus metrics and logs; it has no OpenTelemetry (no OTLP push, no traces across components). - **Wait steps aren't isolated after host losses** (D387): A lost watcher host blames none of its wait steps, and they aren't moved to processes of their own; `worker_watcher_hosts_lost` shows the losses, and this is reconsidered if they show up in real use. ### Operational views - **Record leader and standby masters with heartbeats** (D123): Each running master heartbeats a masters table row with its role and configuration. A master that stops reporting ages out. - **Show node problems on the Deployments graph** (D129): Warnings colour nodes yellow and errors red; panels list current problems. Unreachable webservers are errors and version mismatches warnings; masters report current problems in heartbeats. Lost workers are errors, while disconnected workers, reported warnings and import errors produce warnings. Offline workers have no problems and remain grey and dashed, ignoring stale warnings and import errors. *Not found in the code yet:* offline workers are grey. ### Metrics in the UI - **Masters, workers and the webserver report their memory and CPU** (D463): Each process reports its resident memory and CPU time, and its container's memory now and its limit from the cgroup: a master in its masters row, a worker in its heartbeat (a new field, the protocol's minor version up), the webserver in its `/deployment` answer. A worker splits its memory into the agent itself, its fork servers, its watcher hosts and its running tasks, with its largest tasks named. Not chosen: processes only, without the limit or the breakdown; the UI scraping each process's `/metrics` (no process records that address, and it gives no history). - **The master keeps a sample of each process a minute** (D464): One sample per process a minute (its resident memory and its whole memory with a worker's parts (decision 491), CPU cores since the last, the container's memory and limit, a worker's parts and largest tasks) in `samples` (the open `0002` migration), keyed by process: the leading master writes its masters' and workers' (a standalone one row, its roles master, worker and webserver), a webserver in a process of its own its own. Each closed 15-minute window is rolled up into averages and peaks (a worker's parts averaged over every minute, its largest tasks left out, the latest limit), each row with the `minutes` it covers (and of them with a CPU or container figure, and `covered`: its window's minutes sampled at all), by which a bucket's averages and a deployment's totals are weighted (note 9); minute rows are kept 24 h, rollups 30 d (hidden timings), deleted by the sampler. Not chosen: one a minute for 7 days without a rollup. *Corrected by N9:* Codex's review of M5.1j: totals, parts and limits made exact; buckets in SQL. - **The Metrics endpoints keep their final buckets between requests** (D492): `GET /api/v1/metrics/samples` and `/memory` keep, per range and process (or all), the buckets that ended `FINAL_AFTER` (15 minutes: the sampler's grace, a minute's write, clocks apart) ago, whose rows are all stored, with each process's latest sample; a request reads only the buckets since, and one for a key waits for one already reading it. At most 64 keys (the least recently used no request holds go) of 100,000 buckets each. So the Deployments page's sparkline and the Metrics page cost a few milliseconds a refresh after their first read. *Corrected by N13:* Codex's review of the UI steps M5.1g-l1: seven fixed. ### Metrics page - **Throughput and start latency come from the attempts table** (D494): The Metrics page's throughput and start latency are read from the attempts table, per deployment, over the page's ranges and buckets: attempts ended per bucket by how they ended, and the start latency (`started_at` less `assigned_at`, the worker's start in master time, decision 490) as p50 and p95, exact (the nearest rank), from `GET /api/v1/metrics/tasks`. No worker reports timings, no protocol field, nothing stored in `samples`; partial indexes on `attempts (ended_at)` and `(started_at)` in the open migration, and a range's final buckets kept between requests as the samples' are (decision 492). Not chosen: workers reporting M5.1a's stage timers in their heartbeat (a protocol field, new sample columns), moving the step out of M5.1. ### Other - **Clock and fencing metrics on workers and the master** (D448): Workers export the age of their master-time sample, the round trip it was measured over, and a count of streams ended for an older lease epoch; the master exports the attempts held for a replaced incarnation. The start-slack and `TOO_LATE` metrics went with the start deadline (D460). Not chosen: worker metrics only. ### From other topics - The shim reports process usage without controlling the task (D14, `task-processes`; built M2.5.3) - Spawned process usage is read before the process is reaped (D18, `task-processes`; built M2.5.4b) - Do not retry fork server thread or version failures (D20, `task-processes`; built M2.5.4a) - Offline workers have no problem on the Deployments graph (D130, `workers`; built M4.4b) - A master that is not leading is unready and refuses streams (D297, `components`; built M4.8z) - A late cleanup failure turns a successful run yellow (D309, `cleanup`; built (B169 fixed)) - Library threads in watcher hosts are watched (D339, `wait-steps`; built M4.11a3) - Watcher host crashes and memory kills are visible as losses (D342, `wait-steps`; built M4.11a3) - The Deployments page has a Status block above its graph (D462, `ui-cli`; built M5.1g) - A Metrics page with memory and CPU over time (D465, `ui-cli`; built M5.1j) - A task's peak memory over its attempts is charted (D467, `ui-cli`; built M5.1k) - started_at is the worker's start, in master time (D490, `assignment`; built M5.1m) - A process's memory includes its tasks; memory is split by kind (D491, `ui-cli`; built M5.1j) - The Metrics page folds the processes that ended into one line (D499, `ui-cli`; planned (R1.1)) ## Replaced None. ## Where in code - `crates/schedr-agent/src/agent.rs::publish_master_reading` (D448) - `crates/schedr-agent/src/fork.rs::Cause` (D20) - `crates/schedr-agent/src/jobs.rs` (D297) - `crates/schedr-agent/src/master_time.rs::estimate` (D490) - `crates/schedr-agent/src/memory.rs::RunningMemory` (D463) - `crates/schedr-agent/src/memory.rs::node_usage` (D463) - `crates/schedr-agent/src/metrics.rs::register` (D448) - `crates/schedr-agent/src/process.rs` (D18) - `crates/schedr-agent/src/usage.rs::zombie_usage` (D18) - `crates/schedr-agent/src/watchers.rs::host_lost` (D342) - `crates/schedr-api/src/attempt_memory.rs` (D467) - `crates/schedr-api/src/routes.rs` (D129) - `crates/schedr-api/src/routes.rs::worker_problems` (D130) - `crates/schedr-api/src/series.rs` (D465, D499) - `crates/schedr-api/src/series.rs::list_samples` (D492) - `crates/schedr-api/src/series/cache.rs` (D492) - `crates/schedr-api/src/task_flow.rs::FlowCache` (D494) - `crates/schedr-api/src/task_flow.rs::task_flow` (D494) - `crates/schedr-api/src/views.rs` (D309, D499) - `crates/schedr-api/src/views.rs::ProblemView` (D129) - `crates/schedr-api/src/views.rs::SensorView` (D343) - `crates/schedr-api/src/views.rs::WatcherHostView` (D343) - `crates/schedr-api/src/views.rs::WorkerNodeView` (D462) - `crates/schedr-api/src/views.rs::WorkerUsageView` (D463) - `crates/schedr-db/migrations/postgres/0001_initial.sql::masters` (D123) - `crates/schedr-db/migrations/sqlite/0001_initial.sql::masters` (D123) - `crates/schedr-db/src/attempts.rs::mark_started_many` (D490) - `crates/schedr-db/src/nodes.rs::NodeProblem` (D129) - `crates/schedr-db/src/nodes.rs::set_worker_usage` (D463) - `crates/schedr-db/src/reads.rs::late_failure` (D309) - `crates/schedr-db/src/runs.rs::mark_late_failure` (D309) - `crates/schedr-db/src/samples.rs` (D464) - `crates/schedr-db/src/task_flow.rs::attempts_ended` (D494) - `crates/schedr-db/src/task_flow.rs::start_latency` (D494) - `crates/schedr-db/src/task_memory.rs` (D467) - `crates/schedr-master/src/core.rs::USAGE_EVERY` (D463) - `crates/schedr-master/src/dispatch.rs::end_replaced` (D448) - `crates/schedr-master/src/dispatch.rs::start_time` (D490) - `crates/schedr-master/src/limits.rs::Reached` (D91) - `crates/schedr-master/src/samples.rs::Sampler` (D464) - `crates/schedr-master/src/samples.rs::rolled_up` (D491) - `crates/schedr-master/src/samples.rs::sample_webserver` (D464) - `crates/schedr-master/src/service.rs::NOT_LEADING` (D297) - `crates/schedr-model/src/usage.rs` (D463) - `crates/schedr-ui/src/deployments.rs::status` (D462) - `crates/schedr-ui/src/metrics.rs` (D465, D499) - `crates/schedr-ui/src/metrics.rs::kinds_chart` (D491) - `crates/schedr-ui/src/metrics.rs::parts_chart` (D491) - `crates/schedr-ui/src/metrics/flow.rs::charts` (D494) - `crates/schedr-ui/src/task_memory.rs::memory_chart` (D467) - `crates/schedr-ui/src/task_memory.rs::memory_rows` (D467) - `crates/schedr-ui/templates/deployments.html` (D462) - `crates/schedr-ui/templates/metrics.html` (D465) - `crates/schedr/src/ops.rs::readyz` (D297) - `python/schedr/runner/fork_server.py::_exited` (D14) - `python/schedr/runner/watchers.py::_warn_of_threads` (D339) ## Open - Q28: A ready-to-started line on the Metrics page Proposal: A third series on the Metrics page's start latency: ready → started (`started_at` less the instance's `ready_at`), the wait before any worker takes a task. `ready_at` is overwritten by a retry, so it is exact only for an instance's latest attempt. Not for 1.1.0 (the user, 2026-11-15). Details and edge cases, with the reasons; read them before changing this: - JOURNAL.md: D386, D387, D445, D463, D464, D492, D494 - archive/PROJECT.md: Native API, Sensors and triggers, Web UI and CLI