Documentation
¶
Index ¶
- Constants
- Variables
- func ApplyCommonConfig(target any, common CommonConfig) error
- func ByteCodeFileModeName(mode uint8) string
- func EmbeddedByteCodeFileMode() (uint8, error)
- func MergeReloadOutput(current, candidate any, patch CommonConfigPatch) error
- func ParseByteCodeFileMode(value string) (uint8, error)
- type BaseConfig
- func (c *BaseConfig) Bytes() []byte
- func (c *BaseConfig) EnableGlobalVar() bool
- func (c *BaseConfig) GetAddrType() uint8
- func (c *BaseConfig) GetBTF() uint8
- func (c *BaseConfig) GetBaseConfig() *BaseConfig
- func (c *BaseConfig) GetByteCodeFileMode() uint8
- func (c *BaseConfig) GetCGroupPath() string
- func (c *BaseConfig) GetDebug() bool
- func (c *BaseConfig) GetEcaptureQ() string
- func (c *BaseConfig) GetEventCollectorAddr() string
- func (c *BaseConfig) GetEventRotation() (uint16, uint16)
- func (c *BaseConfig) GetEventWriter() io.Writer
- func (c *BaseConfig) GetHex() bool
- func (c *BaseConfig) GetListen() string
- func (c *BaseConfig) GetLoggerAddr() string
- func (c *BaseConfig) GetPerCpuMapSize() int
- func (c *BaseConfig) GetPerfReorder() (bool, uint64)
- func (c *BaseConfig) GetPid() uint64
- func (c *BaseConfig) GetRuntimeOutput() *outputpipeline.RuntimeDependencies
- func (c *BaseConfig) GetTruncateSize() uint64
- func (c *BaseConfig) GetUid() uint64
- func (c *BaseConfig) PerfReorderLagNs() uint64
- func (c *BaseConfig) SetAddrType(t uint8)
- func (c *BaseConfig) SetBTF(mode uint8)
- func (c *BaseConfig) SetByteCodeFileMode(mode uint8)
- func (c *BaseConfig) SetCGroupPath(path string)
- func (c *BaseConfig) SetDebug(debug bool)
- func (c *BaseConfig) SetEcaptureQ(addr string)
- func (c *BaseConfig) SetEventCollectorAddr(addr string)
- func (c *BaseConfig) SetEventRotation(maxSizeMB, maxSeconds uint16)
- func (c *BaseConfig) SetEventWriter(w io.Writer)
- func (c *BaseConfig) SetHex(hex bool)
- func (c *BaseConfig) SetListen(addr string)
- func (c *BaseConfig) SetLoggerAddr(addr string)
- func (c *BaseConfig) SetPerCpuMapSize(size int)
- func (c *BaseConfig) SetPid(pid uint64)
- func (c *BaseConfig) SetRuntimeOutput(deps *outputpipeline.RuntimeDependencies)
- func (c *BaseConfig) SetTruncateSize(size uint64)
- func (c *BaseConfig) SetUid(uid uint64)
- func (c *BaseConfig) Validate() error
- func (c *BaseConfig) ValidateTextOutput() error
- type BaseConfigProvider
- type CommonConfig
- type CommonConfigPatch
Constants ¶
const ( BTFModeAutoDetect = 0 BTFModeCore = 1 BTFModeNonCore = 2 )
BTF mode constants
const ( ByteCodeFileAll = 0 ByteCodeFileCore = 1 ByteCodeFileNonCore = 2 )
ByteCodeFileMode constants
const DefaultMapSizePerCpu = 8 * 1024 * 1024
DefaultMapSizePerCpu is the default eBPF map size per CPU (8MB).
Variables ¶
var ByteCodeFiles = "all"
ByteCodeFiles is set by the production linker to describe the eBPF assets embedded in the current binary. Keep this as a string variable so Go's -X linker flag can replace it.
Functions ¶
func ApplyCommonConfig ¶ added in v2.8.0
func ApplyCommonConfig(target any, common CommonConfig) error
ApplyCommonConfig applies all serializable common probe settings in one operation. It only mutates fields and never validates or creates output sinks, so repeated application is safe.
func ByteCodeFileModeName ¶ added in v2.8.0
ByteCodeFileModeName returns the build-facing name for an asset mode.
func EmbeddedByteCodeFileMode ¶ added in v2.8.0
EmbeddedByteCodeFileMode returns the asset mode linked into this binary.
func MergeReloadOutput ¶ added in v2.8.0
func MergeReloadOutput(current, candidate any, patch CommonConfigPatch) error
MergeReloadOutput applies the reload inheritance contract for captured-event output. Only omitted fields inherit; explicit empty and zero values are kept. Other common fields retain the concrete config factory's normal defaults or explicitly decoded values.
func ParseByteCodeFileMode ¶ added in v2.8.0
ParseByteCodeFileMode converts the build-time asset mode to its config value.
Types ¶
type BaseConfig ¶
type BaseConfig struct {
Pid uint64 `json:"pid"`
Uid uint64 `json:"uid"`
Debug bool `json:"debug"`
IsHex bool `json:"is_hex"`
BtfMode uint8 `json:"btf_mode"`
ByteCodeFileMode uint8 `json:"byte_code_file_mode"`
PerCpuMapSize int `json:"per_cpu_map_size"`
TruncateSize uint64 `json:"truncate_size"`
LoggerAddr string `json:"logger_addr"`
EventCollectorAddr string `json:"event_collector_addr"`
EventRotateSizeMB uint16 `json:"event_rotate_size_mb"`
EventRotateSeconds uint16 `json:"event_rotate_seconds"`
EcaptureQ string `json:"ecapture_q"`
Listen string `json:"listen"`
AddrType uint8 `json:"addr_type"`
EventWriter io.Writer `json:"-"`
RuntimeOutput *outputpipeline.RuntimeDependencies `json:"-"`
CGroupPath string `json:"cgroup_path"` // cgroup path for container/process filtering
// PerfReorder enables userland lag-reorder of perf buffer events (by bpf ktime) before dispatch.
PerfReorder bool `json:"perf_reorder"`
// PerfReorderLagMs is the lag window in milliseconds when PerfReorder is set. Zero uses default (10 ms).
PerfReorderLagMs uint `json:"perf_reorder_lag_ms"`
}
BaseConfig provides common configuration for all probes.
func BaseConfigFor ¶ added in v2.8.0
func BaseConfigFor(value any) (*BaseConfig, error)
BaseConfigFor returns the common configuration owned by value.
func NewBaseConfig ¶
func NewBaseConfig() *BaseConfig
NewBaseConfig creates a new BaseConfig with default values.
func (*BaseConfig) Bytes ¶
func (c *BaseConfig) Bytes() []byte
Bytes serializes the configuration to JSON.
func (*BaseConfig) EnableGlobalVar ¶
func (c *BaseConfig) EnableGlobalVar() bool
EnableGlobalVar checks if the kernel supports global variables.
func (*BaseConfig) GetAddrType ¶
func (c *BaseConfig) GetAddrType() uint8
GetAddrType returns the logger address type.
func (*BaseConfig) GetBaseConfig ¶ added in v2.8.0
func (c *BaseConfig) GetBaseConfig() *BaseConfig
GetBaseConfig exposes the embedded common configuration to shared CLI and HTTP configuration application code.
func (*BaseConfig) GetByteCodeFileMode ¶
func (c *BaseConfig) GetByteCodeFileMode() uint8
GetByteCodeFileMode returns the bytecode file selection mode.
func (*BaseConfig) GetCGroupPath ¶
func (c *BaseConfig) GetCGroupPath() string
GetCGroupPath returns the cgroup path for filtering.
func (*BaseConfig) GetDebug ¶
func (c *BaseConfig) GetDebug() bool
GetDebug returns whether debug mode is enabled.
func (*BaseConfig) GetEcaptureQ ¶
func (c *BaseConfig) GetEcaptureQ() string
GetEcaptureQ returns the eCaptureQ address.
func (*BaseConfig) GetEventCollectorAddr ¶
func (c *BaseConfig) GetEventCollectorAddr() string
GetEventCollectorAddr returns the event collector address.
func (*BaseConfig) GetEventRotation ¶ added in v2.8.0
func (c *BaseConfig) GetEventRotation() (uint16, uint16)
GetEventRotation returns captured-event rotation limits.
func (*BaseConfig) GetEventWriter ¶
func (c *BaseConfig) GetEventWriter() io.Writer
GetEventWriter returns the pre-configured event writer (e.g., for ecaptureQ).
func (*BaseConfig) GetHex ¶
func (c *BaseConfig) GetHex() bool
GetHex returns whether output should be in hexadecimal format.
func (*BaseConfig) GetListen ¶
func (c *BaseConfig) GetListen() string
GetListen returns the HTTP listen address.
func (*BaseConfig) GetLoggerAddr ¶
func (c *BaseConfig) GetLoggerAddr() string
GetLoggerAddr returns the logger address.
func (*BaseConfig) GetPerCpuMapSize ¶
func (c *BaseConfig) GetPerCpuMapSize() int
GetPerCpuMapSize returns the eBPF map size per CPU.
func (*BaseConfig) GetPerfReorder ¶
func (c *BaseConfig) GetPerfReorder() (bool, uint64)
GetPerfReorder returns whether userland perf reorder is enabled and the lag in nanoseconds.
func (*BaseConfig) GetPid ¶
func (c *BaseConfig) GetPid() uint64
GetPid returns the target process ID.
func (*BaseConfig) GetRuntimeOutput ¶ added in v2.8.0
func (c *BaseConfig) GetRuntimeOutput() *outputpipeline.RuntimeDependencies
GetRuntimeOutput returns borrowed process-lifetime output dependencies.
func (*BaseConfig) GetTruncateSize ¶
func (c *BaseConfig) GetTruncateSize() uint64
GetTruncateSize returns the truncate size for captured data.
func (*BaseConfig) PerfReorderLagNs ¶
func (c *BaseConfig) PerfReorderLagNs() uint64
PerfReorderLagNs returns the reorder lag in nanoseconds. Used when PerfReorder is enabled.
func (*BaseConfig) SetAddrType ¶
func (c *BaseConfig) SetAddrType(t uint8)
SetAddrType sets the logger address type.
func (*BaseConfig) SetByteCodeFileMode ¶
func (c *BaseConfig) SetByteCodeFileMode(mode uint8)
SetByteCodeFileMode sets the bytecode file mode.
func (*BaseConfig) SetCGroupPath ¶
func (c *BaseConfig) SetCGroupPath(path string)
SetCGroupPath sets the cgroup path for filtering.
func (*BaseConfig) SetDebug ¶
func (c *BaseConfig) SetDebug(debug bool)
SetDebug sets the debug mode.
func (*BaseConfig) SetEcaptureQ ¶
func (c *BaseConfig) SetEcaptureQ(addr string)
SetEcaptureQ sets the eCaptureQ address.
func (*BaseConfig) SetEventCollectorAddr ¶
func (c *BaseConfig) SetEventCollectorAddr(addr string)
SetEventCollectorAddr sets the event collector address.
func (*BaseConfig) SetEventRotation ¶ added in v2.8.0
func (c *BaseConfig) SetEventRotation(maxSizeMB, maxSeconds uint16)
SetEventRotation configures rotation for compatible captured-event files.
func (*BaseConfig) SetEventWriter ¶
func (c *BaseConfig) SetEventWriter(w io.Writer)
SetEventWriter sets a pre-configured event writer.
func (*BaseConfig) SetListen ¶
func (c *BaseConfig) SetListen(addr string)
SetListen sets the HTTP listen address.
func (*BaseConfig) SetLoggerAddr ¶
func (c *BaseConfig) SetLoggerAddr(addr string)
SetLoggerAddr sets the logger address.
func (*BaseConfig) SetPerCpuMapSize ¶
func (c *BaseConfig) SetPerCpuMapSize(size int)
SetPerCpuMapSize sets the eBPF map size per CPU.
func (*BaseConfig) SetPid ¶
func (c *BaseConfig) SetPid(pid uint64)
SetPid sets the target process ID.
func (*BaseConfig) SetRuntimeOutput ¶ added in v2.8.0
func (c *BaseConfig) SetRuntimeOutput(deps *outputpipeline.RuntimeDependencies)
SetRuntimeOutput attaches process-lifetime output dependencies. They are excluded from JSON and must be reattached after runtime configuration reload.
func (*BaseConfig) SetTruncateSize ¶
func (c *BaseConfig) SetTruncateSize(size uint64)
SetTruncateSize sets the truncate size.
func (*BaseConfig) Validate ¶
func (c *BaseConfig) Validate() error
Validate checks if the configuration is valid.
func (*BaseConfig) ValidateTextOutput ¶ added in v2.8.0
func (c *BaseConfig) ValidateTextOutput() error
ValidateTextOutput validates the common configuration and the captured-event destination used by probes whose only representation is text. It performs no I/O and is therefore safe to call repeatedly.
type BaseConfigProvider ¶ added in v2.8.0
type BaseConfigProvider interface {
GetBaseConfig() *BaseConfig
}
BaseConfigProvider is implemented by BaseConfig and, through embedding, by every concrete probe configuration.
type CommonConfig ¶ added in v2.8.0
type CommonConfig struct {
Pid uint64
Uid uint64
Debug bool
Hex bool
BTFMode uint8
ByteCodeFileMode uint8
PerCpuMapSize int
TruncateSize uint64
EventCollectorAddr string
EventRotateSizeMB uint16
EventRotateSeconds uint16
CGroupPath string
PerfReorder bool
PerfReorderLagMs uint
}
CommonConfig contains the serializable settings shared by every probe generation. Process-lifetime output dependencies (the operational logger and typed captured-event publishers) deliberately live in output.RuntimeDependencies instead and are never copied through this type.
func CommonConfigFrom ¶ added in v2.8.0
func CommonConfigFrom(value any) (CommonConfig, error)
CommonConfigFrom snapshots the serializable common probe settings.
type CommonConfigPatch ¶ added in v2.8.0
type CommonConfigPatch struct {
Pid *uint64 `json:"pid"`
Uid *uint64 `json:"uid"`
Debug *bool `json:"debug"`
Hex *bool `json:"is_hex"`
BTFMode *uint8 `json:"btf_mode"`
ByteCodeFileMode *uint8 `json:"byte_code_file_mode"`
PerCpuMapSize *int `json:"per_cpu_map_size"`
TruncateSize *uint64 `json:"truncate_size"`
EventCollectorAddr *string `json:"event_collector_addr"`
EventRotateSizeMB *uint16 `json:"event_rotate_size_mb"`
EventRotateSeconds *uint16 `json:"event_rotate_seconds"`
CGroupPath *string `json:"cgroup_path"`
PerfReorder *bool `json:"perf_reorder"`
PerfReorderLagMs *uint `json:"perf_reorder_lag_ms"`
}
CommonConfigPatch records both a JSON value and whether the caller supplied it. Pointer fields are required so an HTTP reload can distinguish an omitted field from an explicit zero value or empty destination.
func DecodeCommonConfigPatch ¶ added in v2.8.0
func DecodeCommonConfigPatch(data []byte) (CommonConfigPatch, error)
DecodeCommonConfigPatch extracts common JSON fields while retaining field presence. Concrete config factories decode the same request body for their module-specific fields.
func (CommonConfigPatch) Apply ¶ added in v2.8.0
func (p CommonConfigPatch) Apply(target any) error
Apply overlays fields supplied by the patch on the target's current common settings. Omitted fields remain unchanged.