workstats

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package workstats counts the work this process does, such as transcripts decoded, git processes run and refresh passes, so a profile of the daemon can say what its CPU time went to and how often each kind of work ran. Counters only ever grow; a reader takes two snapshots and compares them. Counting costs one atomic add, so it is always on.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Add

func Add(name string, delta int64)

Add adds delta to the counter name, creating it at zero.

func Gauge

func Gauge(name string, read func() int64)

Gauge registers a value read when a snapshot is taken, such as a cache's size. A later registration under the same name replaces it.

func Git

func Git(args ...string)

Git counts one git process, in total and by its subcommand: the first argument that is not an option or an option's value.

func Inc

func Inc(name string)

Inc adds one to the counter name.

Types

type Delta

type Delta struct {
	Name  string
	Count int64
}

Delta is how a counter moved between two snapshots.

type Process

type Process struct {
	// UserSeconds and SystemSeconds are CPU time; both are zero where the
	// platform does not report them.
	UserSeconds   float64 `json:"cpu_user_seconds"`
	SystemSeconds float64 `json:"cpu_system_seconds"`
	Goroutines    int     `json:"goroutines"`
	HeapBytes     uint64  `json:"heap_bytes"`
	GCCycles      uint32  `json:"gc_cycles"`
}

Process is the process's resource use since it started.

func (Process) CPUSeconds

func (p Process) CPUSeconds() float64

CPUSeconds is the process's user and system CPU time together.

type Snapshot

type Snapshot struct {
	At       time.Time        `json:"at"`
	Uptime   float64          `json:"uptime_seconds"`
	Process  Process          `json:"process"`
	Counters map[string]int64 `json:"counters"`
	Gauges   map[string]int64 `json:"gauges"`
}

Snapshot is the process's counters and gauges at one moment.

func Take

func Take() Snapshot

Take reads every counter and gauge.

func (Snapshot) Since

func (s Snapshot) Since(earlier Snapshot) []Delta

Since returns the counters that moved from earlier to s, largest first.

Jump to

Keyboard shortcuts

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