Documentation
¶
Index ¶
- type ProcessSample
- type Store
- func (s *Store) Latest() *metrics.SystemSnapshot
- func (s *Store) ProcessHistory(pid uint32) []ProcessSample
- func (s *Store) PruneStaleProcesses(cutoff time.Time) int
- func (s *Store) SetLatest(snap *metrics.SystemSnapshot)
- func (s *Store) SystemHistory() []metrics.TimestampedSystem
- func (s *Store) SystemHistorySince(since time.Time) []metrics.TimestampedSystem
- func (s *Store) TrackedProcessCount() int
- func (s *Store) UpdateLatest(update func(*metrics.SystemSnapshot)) bool
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ProcessSample ¶
type ProcessSample struct {
Time time.Time `json:"time"`
CPUPercent float64 `json:"cpu_percent"`
WorkingSet uint64 `json:"working_set"`
PrivateBytes uint64 `json:"private_bytes"`
IOReadBytes uint64 `json:"io_read_bytes"`
IOWriteBytes uint64 `json:"io_write_bytes"`
ThreadCount uint32 `json:"thread_count"`
}
ProcessSample is a single point in a process's history.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store holds the latest snapshot plus historical ring buffers for system metrics and per-process samples.
func NewStore ¶
NewStore allocates a store sized for `historyCap` system snapshots and `procHistoryCap` samples per process.
func (*Store) Latest ¶
func (s *Store) Latest() *metrics.SystemSnapshot
Latest returns the most recent snapshot or nil if none has been recorded.
func (*Store) ProcessHistory ¶
func (s *Store) ProcessHistory(pid uint32) []ProcessSample
ProcessHistory returns the recorded samples for a single PID.
func (*Store) PruneStaleProcesses ¶
PruneStaleProcesses drops history for any PID not seen since `cutoff`.
func (*Store) SetLatest ¶
func (s *Store) SetLatest(snap *metrics.SystemSnapshot)
SetLatest replaces the latest system snapshot and pushes a timestamped row into the system history ring.
func (*Store) SystemHistory ¶
func (s *Store) SystemHistory() []metrics.TimestampedSystem
SystemHistory returns a copy of the system history ring buffer contents.
func (*Store) SystemHistorySince ¶
func (s *Store) SystemHistorySince(since time.Time) []metrics.TimestampedSystem
SystemHistorySince returns history rows whose timestamp is after `since`.
func (*Store) TrackedProcessCount ¶
TrackedProcessCount returns how many PIDs currently have history buffers.
func (*Store) UpdateLatest ¶ added in v0.2.0
func (s *Store) UpdateLatest(update func(*metrics.SystemSnapshot)) bool
UpdateLatest mutates the latest snapshot in place without appending a new history row. Use this for enriching a previously sampled snapshot with derived data such as process trees or port bindings.