Help us shape the future of Go! Take the 2026 Go Developer Survey

usage

package
v0.31.0 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package usage samples this process's cgroup v2 CPU and memory accounting. In a worker pod that is the pod's own usage as Kubernetes accounts it; the sink for these numbers is the run.heartbeat fact and the worker's OTel instruments.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Sample

type Sample struct {
	CPUSeconds      float64 // cumulative CPU time consumed
	MemoryBytes     int64   // current working set
	MemoryPeakBytes int64   // high-water working set (0 when the kernel doesn't expose it)
}

Sample is one point-in-time read of the cgroup's resource accounting.

func Read

func Read() (Sample, bool)

Read returns the current cgroup v2 usage. ok is false when no cgroup filesystem is available (a dev run outside a pod), in which case callers skip the beat rather than report zeros.

Jump to

Keyboard shortcuts

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