module

package
v0.0.0-...-487e2cc Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2026 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Overview

Package module is the scaffolding for a system-probe module and the loader used upon start

Index

Constants

This section is empty.

Variables

View Source
var ErrNotEnabled = errors.New("module is not enabled")

ErrNotEnabled is a special error type that should be returned by a Factory when the associated Module is not enabled.

Functions

func Close

func Close()

Close each registered module

func GetStats

func GetStats() map[string]any

GetStats returns the stats from all modules, namespaced by their names

func IsLoaded

func IsLoaded(name sysconfigtypes.ModuleName) bool

IsLoaded returns whether the named module has successfully loaded

func Register

func Register(cfg *sysconfigtypes.Config, httpMux *http.ServeMux, factories []*Factory, rcclient rcclient.Component, deps FactoryDependencies) error

Register a set of modules, which involves: * Initialization using the provided Factory; * Registering the HTTP endpoints of each module; * Register the gRPC server;

func RestartModule

func RestartModule(factory *Factory, deps FactoryDependencies) error

RestartModule triggers a module restart

Types

type Factory

type Factory struct {
	Name         sysconfigtypes.ModuleName
	Fn           func(cfg *sysconfigtypes.Config, deps FactoryDependencies) (Module, error)
	NeedsEBPF    func() bool
	OptionalEBPF bool
}

Factory encapsulates the initialization of a Module

type FactoryDependencies

type FactoryDependencies struct {
	fx.In

	SysprobeConfig       sysprobeconfig.Component
	CoreConfig           config.Component
	Log                  log.Component
	WMeta                workloadmeta.Component
	FilterStore          workloadfilter.Component
	Tagger               tagger.Component
	Telemetry            telemetry.Component
	Compression          logscompression.Component
	Secrets              secrets.Component
	Statsd               ddgostatsd.ClientInterface
	Hostname             hostname.Component
	Ipc                  ipc.Component
	Traceroute           traceroute.Component
	ConnectionsForwarder connectionsforwarder.Component
	NPCollector          npcollector.Component
}

FactoryDependencies defines the fx dependencies for a module factory

type Module

type Module interface {
	GetStats() map[string]interface{}
	Register(*Router) error
	Close()
}

Module defines the common API implemented by every System Probe Module

type Router

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

Router provides a wrapper around http.ServeMux so routes can be re-registered. This is needed to support the module-restart feature.

func NewRouter

func NewRouter(namespace string, parent *http.ServeMux) *Router

NewRouter returns a new Router

func (*Router) HandleFunc

func (r *Router) HandleFunc(pattern string, responseWriter func(http.ResponseWriter, *http.Request))

HandleFunc registers a HandleFunc in such a way that routes can be registered multiple times. The pattern follows net/http.ServeMux conventions and may include an HTTP method prefix (e.g. "POST /path").

func (*Router) Unregister

func (r *Router) Unregister()

Unregister removes the registered handler functions

Jump to

Keyboard shortcuts

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