framework

package
v1.4.1 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CleanupInterval     = 600 * time.Second
	ContextExpiredRatio = 20
)

Variables

This section is empty.

Functions

func CollectorsHasStarted

func CollectorsHasStarted(collectors map[string]Collector) bool

func DeviceCollectorsStarted

func DeviceCollectorsStarted(devices map[string]DeviceCollector) bool

Types

type AndPodFilter added in v1.3.0

type AndPodFilter struct {
	Filters []PodFilter
}

func (*AndPodFilter) FilterPod added in v1.3.0

func (a *AndPodFilter) FilterPod(podMeta *statesinformer.PodMeta) (bool, string)

type CPUStat

type CPUStat struct {
	// TODO check CPUTick or CPUUsage can be abandoned
	CPUTick   uint64
	CPUUsage  uint64
	Timestamp time.Time
}

type Collector

type Collector interface {
	Enabled() bool
	Setup(s *Context)
	Run(stopCh <-chan struct{})
	Started() bool
}

type CollectorFactory

type CollectorFactory = func(opt *Options) Collector

type Config

type Config struct {
	CollectResUsedInterval           time.Duration
	CollectSysMetricOutdatedInterval time.Duration
	CollectNodeCPUInfoInterval       time.Duration
	CollectNodeStorageInfoInterval   time.Duration
	CPICollectorInterval             time.Duration
	PSICollectorInterval             time.Duration
	CPICollectorTimeWindow           time.Duration
	ColdPageCollectorInterval        time.Duration
	EnablePageCacheCollector         bool
}

func NewDefaultConfig

func NewDefaultConfig() *Config

func (*Config) InitFlags

func (c *Config) InitFlags(fs *flag.FlagSet)

type Context

type Context struct {
	DeviceCollectors map[string]DeviceCollector
	Collectors       map[string]Collector
	State            *SharedState
}

type DeviceCollector

type DeviceCollector interface {
	Collector
	Shutdown()
	Started() bool
	Infos() metriccache.Devices
	GetNodeMetric() ([]metriccache.MetricSample, error)
	GetPodMetric(uid, podParentDir string, cs []corev1.ContainerStatus) ([]metriccache.MetricSample, error)
	GetContainerMetric(containerID, podParentDir string, c *corev1.ContainerStatus) ([]metriccache.MetricSample, error)
}

type DeviceFactory

type DeviceFactory = func(opt *Options) DeviceCollector

type LatestMetric added in v1.3.0

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

type NothingPodFilter added in v1.3.0

type NothingPodFilter struct{}

func (*NothingPodFilter) FilterPod added in v1.3.0

func (n *NothingPodFilter) FilterPod(podMeta *statesinformer.PodMeta) (bool, string)

type Options

type Options struct {
	Config         *Config
	StatesInformer statesinformer.StatesInformer
	MetricCache    metriccache.MetricCache
	CgroupReader   resourceexecutor.CgroupReader
	PodFilters     map[string]PodFilter
}

type PodCollector added in v1.3.0

type PodCollector interface {
	Collector
	PodFilter
}

type PodFilter added in v1.3.0

type PodFilter interface {
	// FilterPod returns true if the collector should skip collecting the pod.
	FilterPod(podMeta *statesinformer.PodMeta) (shouldSkip bool, msg string)
}
var DefaultPodFilter PodFilter = &NothingPodFilter{}

DefaultPodFilter filters nothing and allows collection for all pods.

func NewAndPodFilter added in v1.3.0

func NewAndPodFilter(filters ...PodFilter) PodFilter

type SharedState added in v1.3.0

type SharedState struct {
	LatestMetric
}

SharedState is for sharing infos across collectors, for example the system resource collector use the result of pod and node resource collector for calculating system usage

func NewSharedState added in v1.3.0

func NewSharedState() *SharedState

func (*SharedState) GetHostAppUsage added in v1.4.0

func (r *SharedState) GetHostAppUsage() (cpu, memory *metriccache.Point)

func (*SharedState) GetNodeUsage added in v1.3.0

func (r *SharedState) GetNodeUsage() (cpu, memory *metriccache.Point)

func (*SharedState) GetPodsUsageByCollector added in v1.3.0

func (r *SharedState) GetPodsUsageByCollector() (cpu, memory map[string]metriccache.Point)

func (*SharedState) UpdateHostAppUsage added in v1.4.0

func (r *SharedState) UpdateHostAppUsage(cpu, memory metriccache.Point)

func (*SharedState) UpdateNodeUsage added in v1.3.0

func (r *SharedState) UpdateNodeUsage(cpu, memory metriccache.Point)

func (*SharedState) UpdatePodUsage added in v1.3.0

func (r *SharedState) UpdatePodUsage(collectorName string, cpu, memory metriccache.Point)

type TerminatedPodFilter added in v1.3.0

type TerminatedPodFilter struct{}

func (*TerminatedPodFilter) FilterPod added in v1.3.0

func (t *TerminatedPodFilter) FilterPod(podMeta *statesinformer.PodMeta) (bool, string)

Jump to

Keyboard shortcuts

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