metric

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2020 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package metric provides metric gathering, in the same way that the Horizontal Pod Autoscaler gathers metrics, using the metrics APIs.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Gather

type Gather struct {
	Resource resource.Gatherer
	Pods     pods.Gatherer
	Object   object.Gatherer
	External external.Gatherer
}

Gather provides functionality for retrieving metrics on supplied metric specs.

func NewGather

func NewGather(
	metricsClient metricsclient.MetricsClient,
	podlister corelisters.PodLister,
	cpuInitializationPeriod time.Duration,
	delayOfInitialReadinessStatus time.Duration) *Gather

NewGather sets up a new Metric Gatherer

func (*Gather) GetMetrics

func (c *Gather) GetMetrics(resource metav1.Object, specs []autoscaling.MetricSpec, namespace string) ([]*Metric, error)

GetMetrics processes each MetricSpec provided, calculating metric values for each and combining them into a slice before returning them. Error will only be returned if all metrics are invalid, otherwise it will return the valid metrics.

type Gatherer

type Gatherer interface {
	GetMetrics(resource metav1.Object, specs []autoscaling.MetricSpec, namespace string) ([]*Metric, error)
}

Gatherer allows retrieval of metrics.

type Metric

type Metric struct {
	CurrentReplicas int32                  `json:"current_replicas"`
	Spec            autoscaling.MetricSpec `json:"spec"`
	Resource        *resource.Metric       `json:"resource,omitempty"`
	Pods            *pods.Metric           `json:"pods,omitempty"`
	Object          *object.Metric         `json:"object,omitempty"`
	External        *external.Metric       `json:"external,omitempty"`
}

Metric represents a metric that has been gathered using a MetricSpec, it can be any of the types of metrics within the CombinedMetric as each is optional. The CombinedMetric also provides the Spec used to gather the metric, alongside the CurrentReplicas at time of gathering.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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