stats

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2026 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Delta

type Delta struct {
	MemoryDelta    int64  // Can be negative if memory freed
	CPUDeltaUsec   uint64 // Always positive (cumulative)
	DiskReadBytes  uint64 // Disk read bytes delta
	DiskWriteBytes uint64 // Disk write bytes delta
	DiskReadOps    uint64 // Read I/O operations delta
	DiskWriteOps   uint64 // Write I/O operations delta
}

Delta represents the difference between two Stats snapshots.

func ComputeDelta

func ComputeDelta(before, after *Stats) *Delta

ComputeDelta calculates the difference between after and before stats.

type Reader

type Reader interface {
	// ReadStats returns current resource metrics for the container.
	ReadStats() (*Stats, error)
	// Close releases any resources held by the reader.
	Close() error
	// Type returns the reader implementation type for logging.
	Type() string // "cgroup" or "docker"
}

Reader is the interface for reading container resource stats. Implemented by cgroupReader (cgroup v2) and dockerReader (Docker Stats API).

func NewReader

func NewReader(
	log logrus.FieldLogger,
	dockerClient *client.Client,
	containerID string,
) (Reader, error)

NewReader creates the best available reader for the container. Priority: 1) Cgroup v2 (low overhead), 2) Docker Stats API (fallback)

type Stats

type Stats struct {
	Memory       uint64 // Current memory usage (bytes)
	CPUUsage     uint64 // CPU usage (microseconds, cumulative)
	DiskRead     uint64 // Disk read (bytes, cumulative)
	DiskWrite    uint64 // Disk write (bytes, cumulative)
	DiskReadOps  uint64 // Disk read operations (cumulative)
	DiskWriteOps uint64 // Disk write operations (cumulative)
}

Stats contains a snapshot of container resource metrics.

Jump to

Keyboard shortcuts

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