metric

package
v0.3.4 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2023 License: Apache-2.0 Imports: 6 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FakeMetricsFetcher

type FakeMetricsFetcher struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func (*FakeMetricsFetcher) AggregateCoreMetric added in v0.2.0

func (f *FakeMetricsFetcher) AggregateCoreMetric(cpuset machine.CPUSet, metricName string, agg metric.Aggregator) metric.MetricData

func (*FakeMetricsFetcher) AggregatePodMetric added in v0.2.0

func (f *FakeMetricsFetcher) AggregatePodMetric(podList []*v1.Pod, metricName string, agg metric.Aggregator, filter metric.ContainerMetricFilter) metric.MetricData

func (*FakeMetricsFetcher) AggregatePodNumaMetric added in v0.2.0

func (f *FakeMetricsFetcher) AggregatePodNumaMetric(podList []*v1.Pod, numaNode, metricName string, agg metric.Aggregator, filter metric.ContainerMetricFilter) metric.MetricData

func (*FakeMetricsFetcher) DeRegisterNotifier

func (f *FakeMetricsFetcher) DeRegisterNotifier(scope MetricsScope, key string)

func (*FakeMetricsFetcher) GetCPUMetric

func (f *FakeMetricsFetcher) GetCPUMetric(coreID int, metricName string) (metric.MetricData, error)

func (*FakeMetricsFetcher) GetCgroupMetric added in v0.3.0

func (f *FakeMetricsFetcher) GetCgroupMetric(cgroupPath, metricName string) (metric.MetricData, error)

func (*FakeMetricsFetcher) GetCgroupNumaMetric added in v0.3.0

func (f *FakeMetricsFetcher) GetCgroupNumaMetric(cgroupPath, numaNode, metricName string) (metric.MetricData, error)

func (*FakeMetricsFetcher) GetContainerMetric

func (f *FakeMetricsFetcher) GetContainerMetric(podUID, containerName, metricName string) (metric.MetricData, error)

func (*FakeMetricsFetcher) GetContainerNumaMetric

func (f *FakeMetricsFetcher) GetContainerNumaMetric(podUID, containerName, numaNode, metricName string) (metric.MetricData, error)

func (*FakeMetricsFetcher) GetDeviceMetric

func (f *FakeMetricsFetcher) GetDeviceMetric(deviceName string, metricName string) (metric.MetricData, error)

func (*FakeMetricsFetcher) GetNodeMetric

func (f *FakeMetricsFetcher) GetNodeMetric(metricName string) (metric.MetricData, error)

func (*FakeMetricsFetcher) GetNumaMetric

func (f *FakeMetricsFetcher) GetNumaMetric(numaID int, metricName string) (metric.MetricData, error)

func (*FakeMetricsFetcher) RegisterExternalMetric added in v0.3.0

func (f *FakeMetricsFetcher) RegisterExternalMetric(fu func(store *metric.MetricStore))

func (*FakeMetricsFetcher) RegisterNotifier

func (f *FakeMetricsFetcher) RegisterNotifier(scope MetricsScope, req NotifiedRequest, response chan NotifiedResponse) string

func (*FakeMetricsFetcher) Run

func (f *FakeMetricsFetcher) Run(ctx context.Context)

func (*FakeMetricsFetcher) SetCPUMetric added in v0.2.0

func (f *FakeMetricsFetcher) SetCPUMetric(cpu int, metricName string, data metric.MetricData)

func (*FakeMetricsFetcher) SetCgroupMetric added in v0.3.0

func (f *FakeMetricsFetcher) SetCgroupMetric(cgroupPath, metricName string, data metric.MetricData)

func (*FakeMetricsFetcher) SetCgroupNumaMetric added in v0.3.0

func (f *FakeMetricsFetcher) SetCgroupNumaMetric(cgroupPath, numaNode, metricName string, data metric.MetricData)

func (*FakeMetricsFetcher) SetContainerMetric

func (f *FakeMetricsFetcher) SetContainerMetric(podUID, containerName, metricName string, data metric.MetricData)

func (*FakeMetricsFetcher) SetContainerNumaMetric

func (f *FakeMetricsFetcher) SetContainerNumaMetric(podUID, containerName, numaNode, metricName string, data metric.MetricData)

func (*FakeMetricsFetcher) SetDeviceMetric added in v0.2.0

func (f *FakeMetricsFetcher) SetDeviceMetric(deviceName string, metricName string, data metric.MetricData)

func (*FakeMetricsFetcher) SetNodeMetric

func (f *FakeMetricsFetcher) SetNodeMetric(metricName string, data metric.MetricData)

func (*FakeMetricsFetcher) SetNumaMetric

func (f *FakeMetricsFetcher) SetNumaMetric(numaID int, metricName string, data metric.MetricData)

type MetricsFetcher

type MetricsFetcher interface {
	// Run starts the preparing logic to collect node metadata.
	Run(ctx context.Context)

	// RegisterNotifier register a channel for raw metric, any time when metric
	// changes, send a data into this given channel along with current time, and
	// we will return a unique key to help with deRegister logic.
	//
	// this "current time" may not represent precisely time when this metric
	// is at, but it indeed is the most precise time katalyst system can provide.
	RegisterNotifier(scope MetricsScope, req NotifiedRequest, response chan NotifiedResponse) string
	DeRegisterNotifier(scope MetricsScope, key string)

	// RegisterExternalMetric register a function to set metric that can
	// only be obtained from external sources
	RegisterExternalMetric(f func(store *metric.MetricStore))

	// GetNodeMetric get metric of node.
	GetNodeMetric(metricName string) (metric.MetricData, error)
	// GetNumaMetric get metric of numa.
	GetNumaMetric(numaID int, metricName string) (metric.MetricData, error)
	// GetDeviceMetric get metric of device.
	GetDeviceMetric(deviceName string, metricName string) (metric.MetricData, error)
	// GetCPUMetric get metric of cpu.
	GetCPUMetric(coreID int, metricName string) (metric.MetricData, error)
	// GetContainerMetric get metric of container.
	GetContainerMetric(podUID, containerName, metricName string) (metric.MetricData, error)
	// GetContainerNumaMetric get metric of container per numa.
	GetContainerNumaMetric(podUID, containerName, numaNode, metricName string) (metric.MetricData, error)

	// AggregatePodNumaMetric handles numa-level metric for all pods
	AggregatePodNumaMetric(podList []*v1.Pod, numaNode, metricName string, agg metric.Aggregator, filter metric.ContainerMetricFilter) metric.MetricData
	// AggregatePodMetric handles metric for all pods
	AggregatePodMetric(podList []*v1.Pod, metricName string, agg metric.Aggregator, filter metric.ContainerMetricFilter) metric.MetricData
	// AggregateCoreMetric handles metric for all cores
	AggregateCoreMetric(cpuset machine.CPUSet, metricName string, agg metric.Aggregator) metric.MetricData

	// GetCgroupMetric get metric of cgroup path: /kubepods/burstable, /kubepods/besteffort, etc.
	GetCgroupMetric(cgroupPath, metricName string) (metric.MetricData, error)
	// GetCgroupNumaMetric get NUMA metric of qos class: /kubepods/burstable, /kubepods/besteffort, etc.
	GetCgroupNumaMetric(cgroupPath, numaNode, metricName string) (metric.MetricData, error)
}

MetricsFetcher is used to get Node and Pod metrics.

func NewFakeMetricsFetcher

func NewFakeMetricsFetcher(emitter metrics.MetricEmitter) MetricsFetcher

NewFakeMetricsFetcher returns a fake MetricsFetcher.

type MetricsScope

type MetricsScope string
const (
	MetricsScopeNode      MetricsScope = "node"
	MetricsScopeNuma      MetricsScope = "numa"
	MetricsScopeCPU       MetricsScope = "cpu"
	MetricsScopeDevice    MetricsScope = "device"
	MetricsScopeContainer MetricsScope = "container"
)

type NotifiedData

type NotifiedData struct {
	Scope    MetricsScope
	Req      NotifiedRequest
	Response chan NotifiedResponse
}

NotifiedData defines the structure as response data for notifier

type NotifiedRequest

type NotifiedRequest struct {
	MetricName string

	DeviceID string
	NumaID   int
	CoreID   int

	PodUID        string
	ContainerName string
	NumaNode      string
}

NotifiedRequest defines the structure as requests for notifier

type NotifiedResponse

type NotifiedResponse struct {
	Req NotifiedRequest
	metric.MetricData
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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