profiler

package
v1.2.27 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2023 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultPeriod specifies the default period at which profiles will be collected.
	DefaultPeriod = 30 * time.Second

	// DefaultDuration specifies the default length of the CPU profile snapshot.
	DefaultDuration = time.Second * 15

	// DefaultUploadTimeout specifies the default timeout for uploading profiles.
	DefaultUploadTimeout = 10 * time.Second
)

Variables

This section is empty.

Functions

func Start

func Start(opts ...Option) error

Start starts the profiler. It may return an error if an API key is not provided by means of the WithAPIKey option, or if a hostname is not found.

func Stop

func Stop()

Stop cancels any ongoing profiling or upload operations and returns after everything has been stopped.

func WithTargetSetter added in v1.2.2

func WithTargetSetter(cfg *Config)

Types

type Config

type Config struct {
	// targetURL is the upload destination URL. It will be set by the profiler on start to either apiURL or agentURL
	// based on the other options.
	Service, Host     string
	Types             map[ProfileType]struct{}
	Period            time.Duration
	CpuDuration       time.Duration
	UploadTimeout     time.Duration
	MaxGoroutinesWait int
	OutputDirFn       func(time.Time) string
	// contains filtered or unexported fields
}

func (*Config) AddProfileType

func (c *Config) AddProfileType(t ProfileType)

type Option

type Option func(*Config)

An Option is used to configure the profiler's behaviour.

func CPUDuration

func CPUDuration(d time.Duration) Option

CPUDuration specifies the length at which to collect CPU profiles.

func WithPeriod

func WithPeriod(d time.Duration) Option

WithPeriod specifies the interval at which to collect profiles.

func WithProfileTypes

func WithProfileTypes(types ...ProfileType) Option

WithProfileTypes specifies the profile types to be collected by the profiler.

func WithService

func WithService(name string) Option

WithService specifies the service name to attach to a profile.

func WithUploadTimeout

func WithUploadTimeout(d time.Duration) Option

WithUploadTimeout specifies the timeout to use for uploading profiles. The default timeout is specified by DefaultUploadTimeout or the DD_PROFILING_UPLOAD_TIMEOUT env variable. Using a negative value or 0 will cause an error when starting the profiler.

func WithUploader

func WithUploader(uploader uploader.IProfileUploader) Option

type ProfileType

type ProfileType int

ProfileType represents a type of profile that the profiler is able to run.

const (
	// HeapProfile reports memory allocation samples; used to monitor current
	// and historical memory usage, and to check for memory leaks.
	HeapProfile ProfileType = iota
	// CPUProfile determines where a program spends its time while actively consuming
	// CPU cycles (as opposed to while sleeping or waiting for I/O).
	CPUProfile
	// GoroutineProfile reports stack traces of all current goroutines
	GoroutineProfile
	// MetricsProfile reports top-line metrics associated with user-specified profiles
	MetricsProfile
)

func (ProfileType) Filename

func (t ProfileType) Filename() string

Filename is the identifier used on upload.

func (ProfileType) String

func (t ProfileType) String() string

String returns the name of the profile.

func (ProfileType) Tag

func (t ProfileType) Tag() string

Tag used on profile metadata

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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