storage

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 25, 2026 License: MIT Imports: 4 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

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

func NewStore(historyCap, procHistoryCap int) *Store

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

func (s *Store) PruneStaleProcesses(cutoff time.Time) int

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

func (s *Store) TrackedProcessCount() int

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL