Documentation ¶
Index ¶
- Variables
- type Collector
- type MetricClient
- type MetricCollector
- func (c *MetricCollector) CreateOrUpdate(metric *av1alpha1.Metric) error
- func (c *MetricCollector) Delete(namespace, name string) error
- func (c *MetricCollector) Inform(event types.NamespacedName)
- func (c *MetricCollector) Record(key types.NamespacedName, stat Stat)
- func (c *MetricCollector) StableAndPanicConcurrency(key types.NamespacedName, now time.Time) (float64, float64, error)
- func (c *MetricCollector) StableAndPanicRPS(key types.NamespacedName, now time.Time) (float64, float64, error)
- func (c *MetricCollector) Watch(fn func(types.NamespacedName))
- type MetricProvider
- func (p *MetricProvider) GetMetricByName(name types.NamespacedName, info provider.CustomMetricInfo, ...) (*cmetrics.MetricValue, error)
- func (p *MetricProvider) GetMetricBySelector(string, labels.Selector, provider.CustomMetricInfo, labels.Selector) (*cmetrics.MetricValueList, error)
- func (p *MetricProvider) ListAllMetrics() []provider.CustomMetricInfo
- type ServiceScraper
- type Stat
- type StatMessage
- type StatsScraper
- type StatsScraperFactory
Constants ¶
This section is empty.
Variables ¶
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") )
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 // Watch registers a singleton function to call when a specific collector's status changes. // The passed name is the namespace/name of the metric owned by the respective collector. Watch(func(types.NamespacedName)) }
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) Inform ¶ added in v0.14.0
func (c *MetricCollector) Inform(event types.NamespacedName)
Inform sends an update to the registered watcher function, if it is set.
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.
func (*MetricCollector) Watch ¶ added in v0.14.0
func (c *MetricCollector) Watch(fn func(types.NamespacedName))
Watch registers a singleton function to call when collector status changes.
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 ¶
func (p *MetricProvider) GetMetricBySelector(string, labels.Selector, provider.CustomMetricInfo, labels.Selector) (*cmetrics.MetricValueList, error)
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.
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.