process

package
v1.8.2 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2024 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Overview

Package process provides all the tools and functionality for sampling processes. It is divided in three main components:

  • Status: provides OS-level information of a process at a given spot
  • Harvester: fetches and creates actual Process Status from system
  • Collector: uses input from the application pipeline to fetch information for all the processes from the instrumented applications, and forwards it to the next stage of the Process' pipeline.

Index

Constants

View Source
const (
	RunModePrivileged   = "privileged"
	RunModeUnprivileged = "unprivileged"
)

Variables

This section is empty.

Functions

func NewCollectorProvider

func NewCollectorProvider(ctx context.Context, input *<-chan []request.Span, cfg *CollectConfig) pipe.StartProvider[[]*Status]

NewCollectorProvider creates and returns a new process Collector, given an agent context.

func OTELGetters

func OTELGetters(name attr.Name) (attributes.Getter[*Status, attribute.KeyValue], bool)

OTELGetters is currently empty as most attributes are resource-level, but left as a placeholder for future attribute additions. nolint:cyclop

func PromGetters

func PromGetters(name attr.Name) (attributes.Getter[*Status, string], bool)

nolint:cyclop

Types

type CPUInfo

type CPUInfo struct {
	// User time of CPU, in seconds
	UserTime float64
	// System time of CPU, in seconds
	SystemTime float64
	// Wait time of CPU, in seconds
	WaitTime float64
}

CPUInfo represents CPU usage statistics at a given point

type CollectConfig

type CollectConfig struct {
	// RunMode defaults to "privileged". A non-privileged harvester will omit some information like open FDs.
	// TODO: move to an upper layer
	RunMode RunMode

	// Interval between harvests
	Interval time.Duration `yaml:"interval" env:"BEYLA_PROCESSES_INTERVAL"`
}

type Collector

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

Collector returns runtime information about the currently running processes. The collector receives each application trace from the newPids internal channel, to know which PIDs are active.

func (*Collector) Collect

func (ps *Collector) Collect(pids map[int32]*svc.ID) ([]*Status, []int32)

Collect returns the status for all the running processes, decorated with Docker runtime information, if applies. It also returns the PIDs that have to be removed from the map, as they do not exist anymore

func (*Collector) Run

func (ps *Collector) Run(out chan<- []*Status)

type Harvester

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

Harvester fetches processes' information from Linux

func (*Harvester) Harvest

func (ps *Harvester) Harvest(svcID *svc.ID) (*Status, error)

Harvest returns a status of a process whose PID is passed as argument. The 'elapsedSeconds' argument represents the time since this process was statusd for the last time. If the process has been statusd for the first time, this value will be ignored

type ID

type ID struct {
	Service *svc.ID

	// UID for a process. Even if the Service field has its own UID,
	// a service might have multiple processes, so Application and Process
	// will be different resources, each one with its own UID,
	// which will be the composition of Service.Instance-ProcessID
	UID svc.UID

	ProcessID       int32
	ParentProcessID int32
	User            string
	Command         string
	CommandArgs     []string
	CommandLine     string
	ExecName        string
	ExecPath        string
}

func (*ID) GetUID

func (i *ID) GetUID() svc.UID

type RunMode

type RunMode string

type Status

type Status struct {
	ID ID

	CPUTimeSystemDelta float64
	CPUTimeUserDelta   float64
	CPUTimeWaitDelta   float64

	CPUUtilisationSystem float64
	CPUUtilisationUser   float64
	CPUUtilisationWait   float64

	// delta values are used in OTEL UpDownCounters while absolute values are used in Prometheus gauges
	MemoryRSSBytes      int64
	MemoryVMSBytes      int64
	MemoryRSSBytesDelta int64
	MemoryVMSBytesDelta int64

	Status      string
	ThreadCount int32
	FdCount     int32

	IOReadCount       uint64
	IOWriteCount      uint64
	IOReadBytesDelta  uint64
	IOWriteBytesDelta uint64

	NetTxBytesDelta  int64
	NetRcvBytesDelta int64
}

Status of a process after being harvested

func NewStatus

func NewStatus(pid int32, svcID *svc.ID) *Status

Jump to

Keyboard shortcuts

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