pprof

package
v0.1.0-alpha.8 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package pprof downloads CPU and memory profiles from a Pyroscope endpoint after each test phase completes.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Downloader

type Downloader struct {
	// contains filtered or unexported fields
}

Downloader downloads CPU and memory pprof profiles from a Pyroscope endpoint.

No K8s dependencies — only knows about an HTTP baseURL and a runID. Port-forwarding is the caller's responsibility. Zero value is invalid; always construct via NewDownloader.

func NewDownloader

func NewDownloader(baseURL, runID string, opts ...Option) *Downloader

NewDownloader returns a Downloader targeting baseURL with the given runID. runID is embedded in every output filename for traceability.

func (*Downloader) DownloadForPhase

func (d *Downloader) DownloadForPhase(ctx context.Context, phaseName string, start, end time.Time)

DownloadForPhase downloads pprof profiles for a completed phase in parallel:

  • CPU profile spanning [start, end] (full phase window)
  • Memory snapshot at [end-60s, end] (lookback window)

Non-fatal: all errors are logged, never returned. Output files: pprof-<runID>-<phaseName>-cpu.pprof

pprof-<runID>-<phaseName>-memory.pprof

type HTTPClient

type HTTPClient interface {
	Do(req *http.Request) (*http.Response, error)
}

HTTPClient is the interface for executing HTTP requests. *http.Client satisfies this interface.

type Option

type Option func(*Downloader)

Option is a functional option for NewDownloader.

func WithAppName

func WithAppName(name string) Option

WithAppName overrides the Pyroscope label filter value (default: "grove-system"). Used as the namespace label selector in Pyroscope queries.

func WithDownloadTimeout

func WithDownloadTimeout(t time.Duration) Option

WithDownloadTimeout sets the per-download timeout (default: 30s).

func WithHTTPClient

func WithHTTPClient(h HTTPClient) Option

WithHTTPClient replaces the default HTTP client (useful for testing).

func WithLogger

func WithLogger(l logr.Logger) Option

WithLogger sets the logger for the downloader.

func WithOutputDir

func WithOutputDir(dir string) Option

WithOutputDir sets the directory for downloaded profile files (default: os.TempDir()).

type ProfileType

type ProfileType string

ProfileType identifies a pprof profile kind exposed by Pyroscope. String value appears in output file names.

const (
	ProfileCPU       ProfileType = "cpu"
	ProfileMemory    ProfileType = "memory"
	ProfileGoroutine ProfileType = "goroutine"
)

Supported profile types for Pyroscope downloads.

func (ProfileType) QueryPrefix

func (p ProfileType) QueryPrefix() string

QueryPrefix returns the Pyroscope metric selector prefix for this profile type. Single source of truth — switch-based, not a mutable package-level map.

Jump to

Keyboard shortcuts

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