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

process

package
v0.25.1 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2023 License: Apache-2.0 Imports: 32 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrProcessMapNotFound = errors.New("perf-map not found")
	ErrProcNotFound       = errors.New("process not found")
)

Functions

This section is empty.

Types

type Cache added in v0.20.0

type Cache[K comparable, V any] interface {
	Add(K, V)
	Get(K) (V, bool)
	Peek(K) (V, bool)
	Remove(K)
}

type DebuginfoManager added in v0.20.0

type DebuginfoManager interface {
	ShouldInitiateUpload(context.Context, string) (bool, error)
	UploadMapping(context.Context, *Mapping) error
	Close() error
}

type Info added in v0.20.0

type Info struct {

	// TODO(kakkoyun): Put all the necessary (following) references in this struct.
	// - PerfMaps, JITDUMP, etc.
	//   * "/proc/%d/root/tmp/perf-%d.map" or "/proc/%d/root/tmp/perf-%d.dump" for PerfMaps
	//   * "/proc/%d/root/jit-%d.dump" for JITDUMP
	// - Unwind Information
	Interpreter *runtime.Interpreter
	Mappings    Mappings
	// contains filtered or unexported fields
}

func (Info) Labels added in v0.20.0

func (i Info) Labels(ctx context.Context) (model.LabelSet, error)

type InfoManager added in v0.20.0

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

func NewInfoManager added in v0.20.0

func NewInfoManager(
	logger log.Logger,
	tracer trace.Tracer,
	reg prometheus.Registerer,
	proceFS procfs.FS,
	objFilePool *objectfile.Pool,
	mm *MapManager,
	dim DebuginfoManager,
	lm LabelManager,
	profilingDuration time.Duration,
	cacheTTL time.Duration,
	fetchInterpreterInfo bool,
) *InfoManager

func (*InfoManager) Close added in v0.20.0

func (im *InfoManager) Close() error

func (*InfoManager) Fetch added in v0.20.0

func (im *InfoManager) Fetch(ctx context.Context, pid int) (Info, error)

func (*InfoManager) Info added in v0.20.0

func (im *InfoManager) Info(ctx context.Context, pid int) (Info, error)

Info returns the cached information for the given process.

func (*InfoManager) Run added in v0.20.0

func (im *InfoManager) Run(ctx context.Context) error

type LabelManager added in v0.20.0

type LabelManager interface {
	Fetch(ctx context.Context, pid int) error
	LabelSet(ctx context.Context, pid int) (model.LabelSet, error)
}

TODO: Unify PID types.

type MapManager added in v0.20.0

type MapManager struct {
	procfs.FS
	// contains filtered or unexported fields
}

func NewMapManager added in v0.20.0

func NewMapManager(
	reg prometheus.Registerer,
	fs procfs.FS,
	objFilePool *objectfile.Pool,
) *MapManager

func (*MapManager) MappingsForPID added in v0.20.0

func (mm *MapManager) MappingsForPID(pid int) (Mappings, error)

MappingsForPID returns all the mappings for the given PID.

func (*MapManager) NewUserMapping added in v0.24.0

func (mm *MapManager) NewUserMapping(pm *procfs.ProcMap, pid int) (*Mapping, error)

newUserMapping makes sure the mapped file is open and computes the kernel offset.

type Mapping

type Mapping struct {
	*procfs.ProcMap

	// Process related fields.
	PID int

	// This will be populated if mappping has executable and symbolizable.
	// We intentionally do NOT use an ObjectFile here.
	// So that it could be GCed and closed.
	// This is needed for pprof conversion.
	BuildID string

	IsJitDump bool

	// This mapping had no path associated with it. Usually this means the
	// mapping is a JIT compiled section.
	NoFileMapping bool
	// contains filtered or unexported fields
}

func (*Mapping) AbsolutePath added in v0.20.0

func (m *Mapping) AbsolutePath() string

AbsolutePath returns path relative to the root namespace of the system.

func (*Mapping) ExecutableInfo added in v0.24.0

func (m *Mapping) ExecutableInfo(addr uint64) (*profilestorepb.ExecutableInfo, error)

Normalize converts the given address to the address relative to the start of the object file.

func (*Mapping) Normalize added in v0.20.0

func (m *Mapping) Normalize(addr uint64) (uint64, error)

func (*Mapping) Root added in v0.20.0

func (m *Mapping) Root() string

Root returns the root filesystem of the process that owns the mapping.

type Mappings added in v0.20.0

type Mappings []*Mapping

func (Mappings) ConvertToPprof added in v0.20.0

func (ms Mappings) ConvertToPprof() []*profile.Mapping

func (Mappings) ExecutableSections added in v0.20.0

func (ms Mappings) ExecutableSections() []*Mapping

func (Mappings) MappingForAddr added in v0.20.0

func (ms Mappings) MappingForAddr(addr uint64) *Mapping

MappingForAddr returns the executable mapping that contains the given address.

type Tree added in v0.13.0

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

func NewTree added in v0.13.0

func NewTree(
	logger log.Logger,
	procfs procfs.FS,
	maxUpdateInterval time.Duration,
) *Tree

NewTree returns a new process tree with current state of all the processes on the system.

func (*Tree) FindAllAncestorProcessIDsInSameCgroup added in v0.13.0

func (t *Tree) FindAllAncestorProcessIDsInSameCgroup(pid int) ([]int, error)

FindAllAncestorProcessIDsInSameCgroup returns all ancestor process IDs for a given PID in the same cgroup.

func (*Tree) Run added in v0.13.0

func (t *Tree) Run(ctx context.Context) error

Run starts the process tree and update it periodically.

Jump to

Keyboard shortcuts

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