probe

package
v0.8.0-alpha Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2023 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Overview

Package probe provides instrumentation probe types and definitions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AllocationConst

type AllocationConst struct{}

AllocationConst is a Const for all the allocation details that need to be injected into an eBPF program.

func (AllocationConst) InjectOption

func (c AllocationConst) InjectOption(td *process.TargetDetails) (inject.Option, error)

InjectOption returns the appropriately configured inject.WithAllocationDetails if the process.AllocationDetails within td are not nil. An error is returned if process.AllocationDetails is nil.

type Base

type Base[BPFObj any, BPFEvent any] struct {
	// Name is the unique name of the instrumentation probe.
	Name string
	// Logger is used to log operations and errors.
	Logger logr.Logger

	// InstrumentedPkg is the package path of the instrumented code.
	InstrumentedPkg string
	// Consts are the constants that need to be injected into the eBPF program
	// that is run by this Probe.
	Consts []Const
	// Uprobes is a mapping from runtime symbols to a UprobeFunc. These define
	// the eBPF program triggers that need to setup for this Probe.
	Uprobes map[string]UprobeFunc[BPFObj]

	// ReaderFn is a creation function for a perf.Reader based on the passed
	// BPFObj related to the probe.
	ReaderFn func(BPFObj) (*perf.Reader, error)
	// SpecFn is a creation function for an eBPF CollectionSpec related to the
	// probe.
	SpecFn func() (*ebpf.CollectionSpec, error)
	// ProcessFn processes probe events into a uniform Event type.
	ProcessFn func(*BPFEvent) *Event
	// contains filtered or unexported fields
}

Base is a base implementation of Probe.

This type can be returned by instrumentation directly. Instrumentation can also wrap this implementation with their own type if they need to override default behavior.

func (*Base[BPFObj, BPFEvent]) Close

func (i *Base[BPFObj, BPFEvent]) Close()

Close stops the Probe.

func (*Base[BPFObj, BPFEvent]) FuncNames

func (i *Base[BPFObj, BPFEvent]) FuncNames() []string

FuncNames returns the fully-qualified function names that are instrumented.

func (*Base[BPFObj, BPFEvent]) LibraryName

func (i *Base[BPFObj, BPFEvent]) LibraryName() string

LibraryName returns the package name being instrumented.

func (*Base[BPFObj, BPFEvent]) Load

func (i *Base[BPFObj, BPFEvent]) Load(exec *link.Executable, td *process.TargetDetails) error

Load loads all instrumentation offsets.

func (*Base[BPFObj, BPFEvent]) Run

func (i *Base[BPFObj, BPFEvent]) Run(dest chan<- *Event)

Run runs the events processing loop.

type Const

type Const interface {
	// InjectOption returns the inject.Option to run for the Const when running
	// inject.Constants.
	InjectOption(td *process.TargetDetails) (inject.Option, error)
}

Const is an constant that needs to be injected into an eBPF program.

type Event

type Event struct {
	Library           string
	Name              string
	Attributes        []attribute.KeyValue
	Kind              trace.SpanKind
	StartTime         int64
	EndTime           int64
	SpanContext       *trace.SpanContext
	ParentSpanContext *trace.SpanContext
}

Event is a telemetry event that happens within an instrumented package.

type KeyValConst

type KeyValConst struct {
	Key string
	Val interface{}
}

KeyValConst is a Const for a generic key-value pair.

This should not be used as a replacement for any of the other provided Const implementations. Those implementations may have added significance and should be used instead where applicable.

func (KeyValConst) InjectOption

func (c KeyValConst) InjectOption(*process.TargetDetails) (inject.Option, error)

InjectOption returns the appropriately configured inject.WithKeyValue.

type Probe

type Probe interface {
	// LibraryName returns the package name being instrumented.
	LibraryName() string

	// FuncNames returns the fully-qualified function names that are
	// instrumented.
	FuncNames() []string

	// Load loads all instrumentation offsets.
	Load(*link.Executable, *process.TargetDetails) error

	// Run runs the events processing loop.
	Run(eventsChan chan<- *Event)

	// Close stops the Probe.
	Close()
}

Probe is the instrument used by instrumentation for a Go package to measure and report on the state of that packages operation.

type RegistersABIConst

type RegistersABIConst struct{}

RegistersABIConst is a Const for the boolean flag informing an eBPF program if the Go space has registered ABI.

func (RegistersABIConst) InjectOption

func (c RegistersABIConst) InjectOption(td *process.TargetDetails) (inject.Option, error)

InjectOption returns the appropriately configured inject.WithRegistersABI.

type StructFieldConst

type StructFieldConst struct {
	Key string
	Val structfield.ID
}

StructFieldConst is a Const for a struct field offset. These struct field ID needs to be known offsets in the inject package.

func (StructFieldConst) InjectOption

func (c StructFieldConst) InjectOption(td *process.TargetDetails) (inject.Option, error)

InjectOption returns the appropriately configured inject.WithOffset if the version of the struct field module is known. If it is not, an error is returned.

type UprobeFunc

type UprobeFunc[BPFObj any] func(symbol string, exec *link.Executable, target *process.TargetDetails, obj *BPFObj) ([]link.Link, error)

UprobeFunc is a function that will attach a eBPF program to a perf event that fires when the given symbol starts executing in exec.

It is expected the symbol belongs to are shared library and its offset can be determined using target.

Losing the reference to the resulting Link (up) will close the Uprobe and prevent further execution of prog. The Link must be Closed during program shutdown to avoid leaking system resources.

Jump to

Keyboard shortcuts

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