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

goprof

package
v0.1.64 Latest Latest
Warning

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

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

Documentation

Overview

Package goprof is a trace kind that reads the pprof profiles of the Go processes of a tree at each checkpoint its host marks: over a process's net/http/pprof server or gops agent, or from a -cpuprofile/-memprofile file a test binary wrote. It stores each profile as its samples aggregated by stack, one record per sample type and stack, and exports them as pprof.

Index

Constants

View Source
const (
	SourcePProf = "pprof"
	SourceGops  = "gops"
	SourceFile  = "file"
)

The sources a profile is read from.

View Source
const Kind = "goprof"

Kind is the name a host registers the kind as.

Variables

View Source
var PProf = tracing.ExportFormat{Name: "pprof", Ext: "pb.gz", MIME: "application/octet-stream"}

PProf is the format a window downloads in as one pprof profile, which go tool pprof reads.

View Source
var Profiles = []string{"cpu", "heap", "allocs", "mutex", "block", "goroutine"}

Profiles are the profiles a checkpoint reads.

Functions

func NewKind

func NewKind(address stacks.AddressFunc) *tracing.Handler[Params, Sample]

NewKind is the goprof kind, reading pprof servers and gops agents at the addresses address gives; nil reads only profile files.

Types

type CheckpointParams

type CheckpointParams struct {
	Key     string `json:"key,omitempty"`
	PID     int    `json:"pid,omitempty"`
	Source  string `json:"source"`
	Profile string `json:"profile"`
	Seconds int    `json:"seconds,omitempty"`
	Path    string `json:"path,omitempty"`
	Reason  string `json:"reason,omitempty"`
}

CheckpointParams are what a checkpoint reads: Profile of the process Key or PID names, the root when neither does, from Source. A cpu profile over pprof runs for Seconds; a gops agent runs it for 30s. A file source reads Path, a profile a process that may have exited wrote, recorded under the key or pid given. Reason is recorded with the samples.

func (CheckpointParams) Validate

func (p CheckpointParams) Validate() error

type Params

type Params struct {
	// RootPID is the process whose tree is profiled; zero is the host's own.
	RootPID int `json:"rootPid,omitempty" clicky:"title=Root PID"`
}

Params choose the tree whose processes a capture profiles.

func (Params) Validate

func (p Params) Validate() error

type Sample

type Sample struct {
	CheckpointID string         `json:"checkpointId" pretty:"hide" filter:"exact"`
	TakenAt      time.Time      `json:"takenAt" pretty:"label=Taken" sort:"takenAt"`
	Reason       string         `json:"reason,omitempty" filter:"terms"`
	Source       string         `json:"source" filter:"terms"`
	Key          string         `json:"key" pretty:"hide" filter:"exact"`
	PID          int            `json:"pid" pretty:"label=PID" filter:"terms"`
	Profile      string         `json:"profile" filter:"terms"`
	SampleType   string         `json:"sampleType" filter:"terms"`
	Unit         string         `json:"unit"`
	Value        int64          `json:"value" sort:"value"`
	Frames       []stacks.Frame `json:"frames" pretty:"hide"`
	StackHash    string         `json:"stackHash" pretty:"hide" filter:"exact"`
}

Sample is the record the kind stores: the value one stack holds of one sample type of a profile, its frames innermost first.

func Aggregate

func Aggregate(head Sample, parsed *profile.Profile) []Sample

Aggregate is the records of parsed, each a copy of head: per sample type, in the profile's order, the value each stack holds, in the order the stacks first appear. A stack that holds nothing of a type has no record of it.

Jump to

Keyboard shortcuts

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