internal

package
v1.59.0 Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2024 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CategoryCPU    = "cpu"
	CategoryMemory = "memory"
	CategoryTime   = "time"
)

Supported profile categories

View Source
const (
	TypeCPUUsage         = "cpu-usage"
	TypeMemoryAllocation = "memory-allocations"
	TypeBlockingCalls    = "blocking-calls"
)

Supported profile types

View Source
const (
	UnitSample      = "sample"
	UnitMillisecond = "millisecond"
	UnitMicrosecond = "microsecond"
	UnitNanosecond  = "nanosecond"
	UnitByte        = "byte"
	UnitKilobyte    = "kilobyte"
	UnitPercent     = "percent"
)

Human-readable measurement units

View Source
const DefaultMaxBufferedProfiles = 100

DefaultMaxBufferedProfiles is the default number of profiles to keep in recorder buffer

View Source
const (
	RuntimeGolang = "golang"
)

Supported profile runtimes

Variables

View Source
var (
	// IncludeProfilerFrames is a setting for the frame filter whether or not to include the profiler
	// frames into the profile
	IncludeProfilerFrames = false
)

Functions

func GenerateUUID

func GenerateUUID() string

GenerateUUID generates a new UUID string

func NoopSendProfiles

func NoopSendProfiles([]AgentProfile) error

NoopSendProfiles is the default function to be called by Recorded to send collected profiles

Types

type AgentCallSite added in v1.13.2

type AgentCallSite struct {
	MethodName  string          `json:"method_name"`
	FileName    string          `json:"file_name"`
	FileLine    int64           `json:"file_line"`
	Measurement float64         `json:"measurement"`
	NumSamples  int64           `json:"num_samples"`
	Children    []AgentCallSite `json:"children"`
}

AgentCallSite is a presenter type used to serialize a call site to JSON format supported by Instana profile sensor

func NewAgentCallSite added in v1.13.2

func NewAgentCallSite(cs *CallSite) AgentCallSite

NewAgentCallSite initializes a new call site payload for the host agent

type AgentProfile added in v1.13.2

type AgentProfile struct {
	ID        string          `json:"id"`
	Runtime   string          `json:"runtime"`
	Category  string          `json:"category"`
	Type      string          `json:"type"`
	Unit      string          `json:"unit"`
	Roots     []AgentCallSite `json:"roots"`
	Duration  int64           `json:"duration"`
	Timespan  int64           `json:"timespan"`
	Timestamp int64           `json:"timestamp"`
}

AgentProfile is a presenter type used to serialize a collected profile to JSON format supported by Instana profile sensor

func NewAgentProfile added in v1.13.2

func NewAgentProfile(p *Profile) AgentProfile

NewAgentProfile creates a new profile payload for the host agent

type AllocationSampler

type AllocationSampler struct{}

AllocationSampler collects information about the number of memory allocations

func NewAllocationSampler

func NewAllocationSampler() *AllocationSampler

NewAllocationSampler initializes a new allocation sampler

func (*AllocationSampler) Profile

func (as *AllocationSampler) Profile(duration int64, timespan int64) (*Profile, error)

Profile retrieves the head profile and converts it to the profile.Profile

func (*AllocationSampler) Reset

func (as *AllocationSampler) Reset()

Reset is a no-op for allocation sampler

func (*AllocationSampler) Start

func (as *AllocationSampler) Start() error

Start is a no-op for allocation sampler

func (*AllocationSampler) Stop

func (as *AllocationSampler) Stop() error

Stop is a no-op for allocation sampler

type BlockSampler

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

BlockSampler collects information about goroutine blocking events, such as waiting on synchronization primitives. This sampler uses the runtime blocking profiler, enabling and disabling it for a period of time.

func NewBlockSampler

func NewBlockSampler() *BlockSampler

NewBlockSampler initializes a new blocking events sampler

func (*BlockSampler) Profile

func (bs *BlockSampler) Profile(duration, timespan int64) (*Profile, error)

Profile return the collected profile for a given time span

func (*BlockSampler) Reset

func (bs *BlockSampler) Reset()

Reset resets the state of a BlockSampler, starting a new call tree

func (*BlockSampler) Start

func (bs *BlockSampler) Start() error

Start enables the reporting of blocking events

func (*BlockSampler) Stop

func (bs *BlockSampler) Stop() error

Stop disables the reporting of blocking events and gathers the collected information into a profile

type CPUSampler

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

CPUSampler collects information about CPU usage

func NewCPUSampler

func NewCPUSampler() *CPUSampler

NewCPUSampler initializes a new CPI sampler

func (*CPUSampler) Profile

func (cs *CPUSampler) Profile(duration int64, timespan int64) (*Profile, error)

Profile returns the recorder profile

func (*CPUSampler) Reset

func (cs *CPUSampler) Reset()

Reset resets the state of a CPUProfiler, starting a new call tree. It does not terminate the profiling, so the gathered profile will make up a new call tree.

func (*CPUSampler) Start

func (cs *CPUSampler) Start() error

Start enables the collection of CPU usage data

func (*CPUSampler) Stop

func (cs *CPUSampler) Stop() error

Stop terminates the collection of CPU usage data and records the collected profile

type CallSite

type CallSite struct {
	MethodName string
	FileName   string
	FileLine   int64
	Metadata   map[string]string
	// contains filtered or unexported fields
}

CallSite represents a recorded method call

func NewCallSite

func NewCallSite(methodName string, fileName string, fileLine int64) *CallSite

NewCallSite initializes a new CallSite

func (*CallSite) FindOrAddChild

func (cs *CallSite) FindOrAddChild(methodName, fileName string, fileLine int64) *CallSite

FindOrAddChild adds a new subcall to a call tree. It returns the existing record the subcall already present

func (*CallSite) Increment

func (cs *CallSite) Increment(value float64, numSamples int64)

Increment increases the sampled measurement while adding up the number of samples used

func (*CallSite) Measurement

func (cs *CallSite) Measurement() (value float64, numSamples int64)

Measurement returns the sampled measurement along with the number of samples

type Flag

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

Flag is a boolean value that can be set and unset atomically

func (*Flag) IsSet

func (f *Flag) IsSet() bool

IsSet returns whether the Flag is set to true

func (*Flag) Set

func (f *Flag) Set()

Set sets the Flag to true

func (*Flag) SetIfUnset

func (f *Flag) SetIfUnset() bool

SetIfUnset sets the Flag to true if it's false and returns whether the value has been changed

func (*Flag) Unset

func (f *Flag) Unset()

Unset sets the Flag to false

func (*Flag) UnsetIfSet

func (f *Flag) UnsetIfSet() bool

UnsetIfSet sets the Flag to false if it's true and returns whether the value has been changed

type Profile

type Profile struct {
	ID        string
	Runtime   string
	Category  string
	Type      string
	Unit      string
	Roots     []*CallSite
	Duration  int64
	Timespan  int64
	Timestamp int64
}

Profile holds the gathered profiling data

func NewProfile

func NewProfile(category string, typ string, unit string, roots []*CallSite, duration int64, timespan int64) *Profile

NewProfile inititalizes a new profile

type Recorder

type Recorder struct {
	FlushInterval       int64
	MaxBufferedProfiles int
	SendProfiles        SendProfilesFunc
	// contains filtered or unexported fields
}

Recorder collects and stores recorded profiles

func NewRecorder

func NewRecorder() *Recorder

NewRecorder initializes and returns a new profile recorder

func (*Recorder) Flush

func (pr *Recorder) Flush()

Flush forces the recorder to submit collected profiles

func (*Recorder) Record

func (pr *Recorder) Record(record AgentProfile)

Record stores collected AgentProfile and enqueues it for submission

func (*Recorder) Size

func (pr *Recorder) Size() int

Size returns the number of profiles enqueued for submission

func (*Recorder) Start

func (pr *Recorder) Start()

Start initiates profile recorder flush loop

func (*Recorder) Stop

func (pr *Recorder) Stop()

Stop terminates profile recorder flush loop

type Sampler

type Sampler interface {
	Profile(duration int64, timespan int64) (*Profile, error)
	Start() error
	Stop() error
	Reset()
}

Sampler gathers continuous profile samples over a period of time

type SamplerConfig

type SamplerConfig struct {
	LogPrefix          string
	ReportOnly         bool
	MaxProfileDuration int64
	MaxSpanDuration    int64
	MaxSpanCount       int32
	SamplingInterval   int64
	ReportInterval     int64
}

SamplerConfig holds profile sampler setting

type SamplerScheduler

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

SamplerScheduler periodically runs the sampler for a time period

func NewSamplerScheduler

func NewSamplerScheduler(profileRecorder *Recorder, samp Sampler, config SamplerConfig) *SamplerScheduler

NewSamplerScheduler initializes a new SamplerScheduler for a sampler

func (*SamplerScheduler) Report

func (ss *SamplerScheduler) Report()

Report retrieves the collected profile from the sampler and enqueues it for submission

func (*SamplerScheduler) Reset

func (ss *SamplerScheduler) Reset()

Reset resets the sampler and clears the internal state of the scheduler

func (*SamplerScheduler) Start

func (ss *SamplerScheduler) Start()

Start runs the SampleScheduler

func (*SamplerScheduler) Stop

func (ss *SamplerScheduler) Stop()

Stop prevents the SamplerScheduler from running the sampler

type SendProfilesFunc

type SendProfilesFunc func([]AgentProfile) error

SendProfilesFunc is a callback to emit collected profiles from recorder

type Timer

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

Timer periodically executes provided job after a delay until it's stopped. Any panic occurred inside the job is recovered and logged

func NewTimer

func NewTimer(delay, interval time.Duration, job func()) *Timer

NewTimer initializes a new Timer

func (*Timer) Stop

func (t *Timer) Stop()

Stop stops the job execution

Directories

Path Synopsis
pprof
profile
Package profile provides a representation of profile.proto and methods to encode/decode profiles in this format.
Package profile provides a representation of profile.proto and methods to encode/decode profiles in this format.

Jump to

Keyboard shortcuts

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