Help us shape the future of Go! Take the 2026 Go Developer Survey

probes

package
v0.51.0 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2026 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Overview

Package probes attaches paired entry/exit uprobes declared in a YAML config to user-space binaries observed by the agent and streams scope-duration events to the configured remote-store as OTLP logs.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ProbeSpec

type ProbeSpec struct {
	SpecID         uint32
	ID             string
	FileMatch      string
	FileMatchRE    *regexp.Regexp
	EntrySymbol    string
	ExitSymbol     string
	MainThreadOnly bool
	MinDurationMs  uint32
}

ProbeSpec is one entry parsed from the probe-config YAML, augmented with a 1-based spec_id assigned at parse time. Each spec describes a paired entry/exit uprobe pair whose duration is measured in BPF.

func LoadConfig

func LoadConfig(path string) ([]ProbeSpec, error)

LoadConfig reads and parses a probe-config YAML file. Required fields per entry: `id`, `file_match`, `entry_symbol`, `exit_symbol`. Defaults: main_thread_only=true, min_duration_ms=0.

`file_match` is usually matched against the executable's absolute path (from args.Mapping.Path), but for cache catch-up and any code path where the absolute path is unavailable, the executable's basename is used as a fallback. Probe regexes should accept either form, e.g. `(^|/)node$`.

func (ProbeSpec) Cookie

func (s ProbeSpec) Cookie() uint64

Cookie returns the 64-bit value passed via UprobeOptions.Cookie to both the entry and exit BPF programs. Layout:

bits 63..32 : spec_id  (uint32, 1-based)
bits 31..1  : min_duration_ms (31 bits, ~24 days max)
bit  0      : main_thread_only flag

type Service

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

Service owns the BPF programs, the attach worker, and the ringbuf drain loop. Drained events are emitted as OTel spans via the Tracer handed out by reporter.ParcaReporter; the reporter owns the underlying OTLP pipeline (queue, batch, retry, transport). Construct with Start, tear down with Close.

func Start

Start parses the YAML, loads the BPF programs, and spawns the drain and attach goroutines. It does NOT attach any uprobes yet -- those happen as OnExecutable is invoked by the profiler for each newly-observed binary.

func (*Service) Close

func (s *Service) Close() error

Close cancels the service's root context, waits for goroutines to drain, closes attached uprobe links, and releases BPF resources.

Closing the ringbuf reader is required BEFORE waiting on the WaitGroup: the drain goroutine is parked inside reader.Read(), which only returns when an event arrives or the reader is closed. The drain loop's ctx.Done check at the top of each iteration never gets revisited while Read is blocked, so cancelling the context alone is not enough to unblock it. Closing the reader makes Read return; the drain loop then sees the already-cancelled context and exits.

func (*Service) OnExecutable

func (s *Service) OnExecutable(filePath string, fileID libpf.FileID)

OnExecutable forwards a newly-observed binary to the attach worker. Safe to call from any goroutine; cheap on the hot path.

type StartConfig

type StartConfig struct {
	ConfigPath string // path to probe-config YAML; required
}

StartConfig is the small bag of parameters Service.Start needs in addition to the YAML probe-config path.

Jump to

Keyboard shortcuts

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