metrics

package
v0.7.0 Latest Latest
Warning

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

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

Documentation

Overview

Package metrics instruments to read and cache Node Metrics from the custom metrics API.

Index

Constants

This section is empty.

Variables

View Source
var InstanceOfMockMetricClientMap = map[string]NodeMetricsInfo{
	"dummyMetric1": TestNodeMetricCustomInfo([]string{"node A", "node B"}, []int64{50, 30}),
	"dummyMetric2": TestNodeMetricCustomInfo([]string{"node A", "node B"}, []int64{50, 30}),
	"dummyMetric3": TestNodeMetricCustomInfo([]string{"node A", "node B"}, []int64{50, 30}),
}

InstanceOfMockMetricClientMap refers to the metrics from Nodes.

Functions

func DummyRestClientConfig

func DummyRestClientConfig() *restclient.Config

DummyRestClientConfig Mocks used for testing in the metrics and other packages.

Types

type Client

type Client interface {
	GetNodeMetric(metricName string) (NodeMetricsInfo, error)
}

Client knows how to query CustomMetricsAPI to return Node Metrics.

func NewDummyMetricsClient

func NewDummyMetricsClient(cache map[string]NodeMetricsInfo) Client

NewDummyMetricsClient receives the Node metrics and return the map values of client.

type CustomMetricsClient

type CustomMetricsClient struct {
	customclient.CustomMetricsClient
}

CustomMetricsClient embeds a client for the custom Metrics API.

func NewClient

func NewClient(config *restclient.Config) CustomMetricsClient

NewClient creates a new Metrics Client including discovering and mapping the available APIs, and pulling the API version.

func (CustomMetricsClient) GetNodeMetric

func (c CustomMetricsClient) GetNodeMetric(metricName string) (NodeMetricsInfo, error)

GetNodeMetric gets the given metric, time Window for Metric and timestamp for each node in the cluster.

type DummyMetricsClient

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

DummyMetricsClient structured with a map of NodeMetricsInfo.

func (DummyMetricsClient) GetNodeMetric

func (d DummyMetricsClient) GetNodeMetric(metricName string) (NodeMetricsInfo, error)

GetNodeMetric returns the NodeMetricsInfo of a metric when it exists.

type NodeMetric

type NodeMetric struct {
	Timestamp time.Time
	Window    time.Duration
	Value     resource.Quantity
}

NodeMetric holds information on a single piece of telemetry data.

type NodeMetricsInfo

type NodeMetricsInfo map[string]NodeMetric

NodeMetricsInfo holds a map of metric information related to a single named metric. The key for the map is the name of the node.

func TestNodeMetricCustomInfo

func TestNodeMetricCustomInfo(nodeNames []string, numbers []int64) NodeMetricsInfo

TestNodeMetricCustomInfo returns slice with NodeMetrics from a arrays of nodesNames and numbers.

Jump to

Keyboard shortcuts

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