Documentation
¶
Overview ¶
Package procstats reports a process's own resource usage — CPU time and resident memory — for nodes to include in their heartbeats. Neither figure is available from the Go standard library: runtime.MemStats describes the Go heap, not the process's actual memory footprint, and there is no standard-library equivalent of CPU accounting at all. Both need an OS-specific query, which is what this package delegates to gopsutil for.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Self ¶
type Self struct {
// contains filtered or unexported fields
}
Self measures the current process's own resource usage.
func NewSelf ¶
func NewSelf() *Self
NewSelf prepares a reader for the current process.
Never fails: if the underlying OS handle cannot be opened, Usage simply reports zero from then on. A heartbeat missing this detail is far less costly than plumbing a constructor error through for something this minor.
func (*Self) Usage ¶
Usage reports this process's CPU use — a percentage averaged over its whole life so far, where 100 means one full core sustained — and its resident memory in bytes. Either figure comes back zero if the underlying OS query fails, which is treated as "unknown right now" rather than an error worth surfacing.