-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Milestone
Description
Problem
The overload middleware needs CPU utilization to make shedding decisions. CPU monitoring exists in internal/cpumon (Linux: /proc/stat, other: runtime/metrics) but is not exposed through the public API.
Unblocks
- Overload Management middleware (fix: io_uring send queue corruption under concurrent writes #34) — 5-stage CPU degradation ladder
Change
// observe/collector.go — add to Snapshot:
CPUUtilization float64 // 0.0–1.0; -1 if unavailable
// observe/collector.go — add CPU monitor support to Collector:
func (c *Collector) SetCPUMonitor(m CPUMonitor) { c.cpuMon = m }
// observe/cpumon.go — public interface + constructor:
type CPUMonitor interface {
Sample() (float64, error) // returns 0.0–1.0
}
// NewCPUMonitor() CPUMonitor — returns platform-appropriate implementation
// (linux: /proc/stat, other: runtime/metrics)
// Thin wrapper around internal/cpumon to keep the internal package internal.In Snapshot(), if cpuMon != nil, call Sample() and populate CPUUtilization. Otherwise set to -1.
Performance
CPU sampling only happens during Snapshot() calls (Prometheus scrape, ~every 15s). Zero cost on the hot path. The cpuMon field is a nil-checked interface on Collector, not on Context.
Files
observe/collector.goobserve/cpumon.go(new)internal/cpumon/(keep internal, wrap)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels