profiling

package
v1.12.9 Latest Latest
Warning

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

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

Documentation

Overview

Package profiling resolves forge's continuous profiling config and runs the Pyroscope push profiler. The span labels that link a trace to its CPU profile live in internal/telemetry, next to the server span.

Index

Constants

This section is empty.

Variables

View Source
var DefaultProfileTypes = []string{"cpu", "alloc_objects", "alloc_space", "inuse_objects", "inuse_space"}

DefaultProfileTypes is what the Pyroscope SDK collects by default.

Functions

This section is empty.

Types

type Inputs

type Inputs struct {
	Code           shared.ProfilingConfig // from WithAppProfilingConfig
	File           shared.ProfilingConfig // from the forge config "profiling" key
	AppName        string
	AppVersion     string
	Environment    string
	TracingEnabled bool
	Getenv         func(string) string
}

Inputs is everything Resolve reads.

type Profiler

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

Profiler pushes profiles to Pyroscope while the app runs.

func New

func New(s Settings, log logger.Logger) *Profiler

New returns a Profiler for s. Nothing runs until Start.

func (*Profiler) Running

func (p *Profiler) Running() bool

Running reports whether push is active.

func (*Profiler) Settings

func (p *Profiler) Settings() Settings

Settings returns the resolved settings.

func (*Profiler) Start

func (p *Profiler) Start() error

Start begins pushing profiles. It does nothing when push isn't configured or the profiler already runs. An unreachable Pyroscope is not an error here: the SDK uploads in the background and logs what fails.

func (*Profiler) Stop

func (p *Profiler) Stop(ctx context.Context) error

Stop uploads what is left and stops. pyroscope's Stop takes no context, so it runs on its own goroutine, and Stop returns ctx.Err() if ctx ends first. The upload then gives up on the SDK's 30 second HTTP timeout.

type Settings

type Settings struct {
	Push              bool // a server address is set
	SpanLabels        bool
	ServerAddress     string
	ApplicationName   string
	BasicAuthUser     string
	BasicAuthPassword string
	TenantID          string
	Tags              map[string]string
	ProfileTypes      []string
	Warnings          []string
}

Settings is the resolved profiling configuration.

func Resolve

func Resolve(in Inputs) Settings

Resolve applies the precedence code, forge config, PYROSCOPE_* env, default.

Jump to

Keyboard shortcuts

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