profiler

package
v0.0.0-...-28e7a36 Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EBPFManager

type EBPFManager struct {
	Config config.EBPFConfig
}

EBPFManager manages loading and attaching of eBPF programs

func NewEBPFManager

func NewEBPFManager(cfg config.EBPFConfig) *EBPFManager

func (*EBPFManager) LoadAndAttach

func (m *EBPFManager) LoadAndAttach(ctx context.Context) error

LoadAndAttach attempts to load the embedded eBPF programs Note: In a real scenario, this would use 'cilium/ebpf' to load the ELF file. Since we cannot compile C code here, this serves as the architectural implementation.

type KernelMonitor

type KernelMonitor struct {
	Enabled bool
}

KernelMonitor simulates eBPF-like observability by reading procfs

func NewKernelMonitor

func NewKernelMonitor() *KernelMonitor

func (*KernelMonitor) CaptureStats

func (k *KernelMonitor) CaptureStats() (*SystemStats, error)

CaptureStats reads /proc/stat and /proc/net/snmp

func (*KernelMonitor) FormatStats

func (k *KernelMonitor) FormatStats(s *SystemStats) string

type ProfileSnapshot

type ProfileSnapshot struct {
	Timestamp time.Time
	Type      string
	Data      []byte
}

ProfileSnapshot stores a profile taken during continuous profiling

type Profiler

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

Profiler manages pprof and other diagnostic tools

func NewProfiler

func NewProfiler(cfg config.PProfConfig) *Profiler

func (*Profiler) CaptureBlockProfile

func (p *Profiler) CaptureBlockProfile(ctx context.Context, duration time.Duration) ([]byte, error)

CaptureBlockProfile captures blocking profile

func (*Profiler) CaptureCPUProfile

func (p *Profiler) CaptureCPUProfile(ctx context.Context, duration time.Duration) ([]byte, error)

CaptureCPUProfile captures CPU profile for duration

func (*Profiler) CaptureGoroutineProfile

func (p *Profiler) CaptureGoroutineProfile() ([]byte, error)

CaptureGoroutineProfile captures current Goroutine profile

func (*Profiler) CaptureHeapProfile

func (p *Profiler) CaptureHeapProfile() ([]byte, error)

CaptureHeapProfile captures current Heap profile

func (*Profiler) CaptureMutexProfile

func (p *Profiler) CaptureMutexProfile(ctx context.Context, duration time.Duration) ([]byte, error)

CaptureMutexProfile captures mutex contention profile

func (*Profiler) CaptureThreadCreateProfile

func (p *Profiler) CaptureThreadCreateProfile() ([]byte, error)

CaptureThreadCreateProfile captures thread creation profile

func (*Profiler) CaptureTrace

func (p *Profiler) CaptureTrace(ctx context.Context, duration time.Duration) ([]byte, error)

CaptureTrace captures runtime trace

func (*Profiler) EnsureRunning

func (p *Profiler) EnsureRunning() error

EnsureRunning checks if pprof is accessible, if not and AutoStart is true, starts it.

func (*Profiler) GetRecentSnapshots

func (p *Profiler) GetRecentSnapshots(duration time.Duration) []ProfileSnapshot

GetRecentSnapshots returns snapshots from the last duration

func (*Profiler) StartContinuous

func (p *Profiler) StartContinuous()

StartContinuous starts the background loop for continuous profiling

func (*Profiler) StopContinuous

func (p *Profiler) StopContinuous()

StopContinuous stops the background loop

type SystemStats

type SystemStats struct {
	ContextSwitches uint64
	ProcsRunning    uint64
	ProcsBlocked    uint64
	TCPActive       uint64
	TCPPassive      uint64
	TCPFailed       uint64
	TCPResets       uint64
	TCPConns        uint64
}

SystemStats holds kernel level stats

Jump to

Keyboard shortcuts

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