tracer

package
v0.0.6-colasoft Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2024 License: Apache-2.0 Imports: 48 Imported by: 0

Documentation

Overview

Package tracer contains functionality for populating tracers.

Index

Constants

View Source
const (
	// ProbabilisticThresholdMax defines the upper bound of the probabilistic profiling
	// threshold.
	ProbabilisticThresholdMax = 100
)

Variables

This section is empty.

Functions

func GetCurrentKernelVersion

func GetCurrentKernelVersion() (major, minor, patch uint32, err error)

GetCurrentKernelVersion returns the major, minor and patch version of the kernel of the host from the utsname struct.

func ProbeBPFSyscall

func ProbeBPFSyscall() error

ProbeBPFSyscall checks if the syscall EBPF is available on the system.

Types

type Config

type Config struct {
	// Reporter allows swapping out the reporter implementation.
	Reporter reporter.SymbolReporter
	// Intervals provides access to globally configured timers and counters.
	Intervals Intervals
	// IncludeTracers holds information about which tracers are enabled.
	IncludeTracers types.IncludedTracers
	// SamplesPerSecond holds the number of samples per second.
	SamplesPerSecond int
	// MapScaleFactor is the scaling factor for eBPF map sizes.
	MapScaleFactor int
	// FilterErrorFrames indicates whether error frames should be filtered.
	FilterErrorFrames bool
	// KernelVersionCheck indicates whether the kernel version should be checked.
	KernelVersionCheck bool
	// DebugTracer indicates whether to load the debug version of eBPF tracers.
	DebugTracer bool
	// BPFVerifierLogLevel is the log level of the eBPF verifier output.
	BPFVerifierLogLevel uint32
	// ProbabilisticInterval is the time interval for which probabilistic profiling will be enabled.
	ProbabilisticInterval time.Duration
	// ProbabilisticThreshold is the threshold for probabilistic profiling.
	ProbabilisticThreshold uint
}

type Intervals

type Intervals interface {
	MonitorInterval() time.Duration
	TracePollInterval() time.Duration
	PIDCleanupInterval() time.Duration
}

Intervals is a subset of config.IntervalsAndTimers.

type Tracer

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

Tracer provides an interface for loading and initializing the eBPF components as well as for monitoring the output maps for new traces and count updates.

func NewTracer

func NewTracer(ctx context.Context, cfg *Config) (*Tracer, error)

NewTracer loads eBPF code and map definitions from the ELF module at the configured path.

func (*Tracer) AttachSchedMonitor

func (t *Tracer) AttachSchedMonitor() error

AttachSchedMonitor attaches a kprobe to the process scheduler. This hook detects the exit of a process and enables us to clean up data we associated with this process.

func (*Tracer) AttachTracer

func (t *Tracer) AttachTracer() error

AttachTracer attaches the main tracer entry point to the perf interrupt events. The tracer entry point is always the native tracer. The native tracer will determine when to invoke the interpreter tracers based on address range information.

func (*Tracer) Close

func (t *Tracer) Close()

Close provides functionality for Tracer to perform cleanup tasks. NOTE: Close may be called multiple times in succession.

func (*Tracer) EnableProfiling

func (t *Tracer) EnableProfiling() error

EnableProfiling enables the perf interrupt events with the attached eBPF programs.

func (*Tracer) StartMapMonitors

func (t *Tracer) StartMapMonitors(ctx context.Context, traceOutChan chan *host.Trace) error

StartMapMonitors starts goroutines for collecting metrics and monitoring eBPF maps for tracepoints, new traces, trace count updates and unknown PCs.

func (*Tracer) StartPIDEventProcessor

func (t *Tracer) StartPIDEventProcessor(ctx context.Context)

StartPIDEventProcessor spawns a goroutine to process PID events.

func (*Tracer) StartProbabilisticProfiling

func (t *Tracer) StartProbabilisticProfiling(ctx context.Context)

StartProbabilisticProfiling periodically runs probabilistic profiling.

func (*Tracer) TraceProcessor

func (t *Tracer) TraceProcessor() tracehandler.TraceProcessor

TraceProcessor gets the trace processor.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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