metrics

package
v0.13.3 Latest Latest
Warning

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

Go to latest
Published: May 13, 2020 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNoData denotes that the collector could not calculate data.
	ErrNoData = errors.New("no data available")

	// ErrNotScraping denotes that the collector is not collecting metrics for the given resource.
	ErrNotScraping = errors.New("the requested resource is not being scraped")
)
View Source
var (
	// ErrFailedGetEndpoints specifies the error returned by scraper when it fails to
	// get endpoints.
	ErrFailedGetEndpoints = errors.New("failed to get endpoints")

	// ErrDidNotReceiveStat specifies the error returned by scraper when it does not receive
	// stat from an unscraped pod
	ErrDidNotReceiveStat = errors.New("did not receive stat from an unscraped pod")
)

Functions

This section is empty.

Types

type Collector

type Collector interface {
	// CreateOrUpdate either creates a collection for the given metric or update it, should
	// it already exist.
	CreateOrUpdate(*av1alpha1.Metric) error
	// Record allows stats to be captured that came from outside the Collector.
	Record(key types.NamespacedName, stat Stat)
	// Delete deletes a Metric and halts collection.
	Delete(string, string) error
}

Collector starts and stops metric collection for a given entity.

type MetricClient

type MetricClient interface {
	// StableAndPanicConcurrency returns both the stable and the panic concurrency
	// for the given replica as of the given time.
	StableAndPanicConcurrency(key types.NamespacedName, now time.Time) (float64, float64, error)

	// StableAndPanicRPS returns both the stable and the panic RPS
	// for the given replica as of the given time.
	StableAndPanicRPS(key types.NamespacedName, now time.Time) (float64, float64, error)
}

MetricClient surfaces the metrics that can be obtained via the collector.

type MetricCollector

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

MetricCollector manages collection of metrics for many entities.

func NewMetricCollector

func NewMetricCollector(statsScraperFactory StatsScraperFactory, logger *zap.SugaredLogger) *MetricCollector

NewMetricCollector creates a new metric collector.

func (*MetricCollector) CreateOrUpdate

func (c *MetricCollector) CreateOrUpdate(metric *av1alpha1.Metric) error

CreateOrUpdate either creates a collection for the given metric or update it, should it already exist. Map access optimized via double-checked locking.

func (*MetricCollector) Delete

func (c *MetricCollector) Delete(namespace, name string) error

Delete deletes a Metric and halts collection.

func (*MetricCollector) Record

func (c *MetricCollector) Record(key types.NamespacedName, stat Stat)

Record records a stat that's been generated outside of the metric collector.

func (*MetricCollector) StableAndPanicConcurrency

func (c *MetricCollector) StableAndPanicConcurrency(key types.NamespacedName, now time.Time) (float64, float64, error)

StableAndPanicConcurrency returns both the stable and the panic concurrency. It may truncate metric buckets as a side-effect.

func (*MetricCollector) StableAndPanicRPS

func (c *MetricCollector) StableAndPanicRPS(key types.NamespacedName, now time.Time) (float64, float64, error)

StableAndPanicRPS returns both the stable and the panic RPS. It may truncate metric buckets as a side-effect.

type MetricProvider

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

MetricProvider is a provider to back a custom-metrics API implementation.

func NewMetricProvider

func NewMetricProvider(metricClient MetricClient) *MetricProvider

NewMetricProvider creates a new MetricProvider.

func (*MetricProvider) GetMetricByName

func (p *MetricProvider) GetMetricByName(name types.NamespacedName, info provider.CustomMetricInfo,
	metricSelector labels.Selector) (*cmetrics.MetricValue, error)

GetMetricByName implements the interface.

func (*MetricProvider) GetMetricBySelector

GetMetricBySelector implements the interface.

func (*MetricProvider) ListAllMetrics

func (p *MetricProvider) ListAllMetrics() []provider.CustomMetricInfo

ListAllMetrics implements the interface.

type ServiceScraper

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

ServiceScraper scrapes Revision metrics via a K8S service by sampling. Which pod to be picked up to serve the request is decided by K8S. Please see https://kubernetes.io/docs/concepts/services-networking/network-policies/ for details.

func NewServiceScraper

func NewServiceScraper(metric *av1alpha1.Metric, counter resources.EndpointsCounter) (*ServiceScraper, error)

NewServiceScraper creates a new StatsScraper for the Revision which the given Metric is responsible for.

func (*ServiceScraper) Scrape

func (s *ServiceScraper) Scrape(window time.Duration) (Stat, error)

Scrape calls the destination service then sends it to the given stats channel.

type Stat

type Stat struct {
	// The time the data point was received by autoscaler.
	Time time.Time

	// The unique identity of this pod.  Used to count how many pods
	// are contributing to the metrics.
	PodName string

	// Average number of requests currently being handled by this pod.
	AverageConcurrentRequests float64

	// Part of AverageConcurrentRequests, for requests going through a proxy.
	AverageProxiedConcurrentRequests float64

	// Number of requests received since last Stat (approximately requests per second).
	RequestCount float64

	// Part of RequestCount, for requests going through a proxy.
	ProxiedRequestCount float64

	// Process uptime in seconds.
	ProcessUptime float64
}

Stat defines a single measurement at a point in time

type StatMessage

type StatMessage struct {
	Key  types.NamespacedName
	Stat Stat
}

StatMessage wraps a Stat with identifying information so it can be routed to the correct receiver.

type StatsScraper

type StatsScraper interface {
	// Scrape scrapes the Revision queue metric endpoint. The duration is used
	// to cutoff young pods, whose stats might skew lower.
	Scrape(time.Duration) (Stat, error)
}

StatsScraper defines the interface for collecting Revision metrics

type StatsScraperFactory

type StatsScraperFactory func(*av1alpha1.Metric) (StatsScraper, error)

StatsScraperFactory creates a StatsScraper for a given Metric.

Jump to

Keyboard shortcuts

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