metrics

package
v0.43.0 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2024 License: Apache-2.0 Imports: 34 Imported by: 10

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")

	// ErrNotCollecting denotes that the collector is not collecting metrics for the given resource.
	ErrNotCollecting = errors.New("no metrics are being collected for the requested resource")
)
View Source
var (
	ErrInvalidLengthStat        = fmt.Errorf("proto: negative length found during unmarshaling")
	ErrIntOverflowStat          = fmt.Errorf("proto: integer overflow")
	ErrUnexpectedEndOfGroupStat = fmt.Errorf("proto: unexpected end of group")
)
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(metric *autoscalingv1alpha1.Metric) error
	// Record allows stats to be captured that came from outside the Collector.
	Record(key types.NamespacedName, now time.Time, stat Stat)
	// Delete deletes a Metric and halts collection.
	Delete(string, string)
	// 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 *autoscalingv1alpha1.Metric) error

CreateOrUpdate either creates a collection for the given metric or update it, should it already exist.

func (*MetricCollector) Delete

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

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, now time.Time, 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 Stat

type Stat struct {
	// The unique identity of this pod.  Used to count how many pods
	// are contributing to the metrics.
	PodName string `protobuf:"bytes,1,opt,name=pod_name,json=podName,proto3" json:"pod_name,omitempty"`
	// Average number of requests currently being handled by this pod.
	AverageConcurrentRequests float64 `` /* 140-byte string literal not displayed */
	// Part of AverageConcurrentRequests, for requests going through a proxy.
	AverageProxiedConcurrentRequests float64 `` /* 163-byte string literal not displayed */
	// Number of requests received since last Stat (approximately requests per second).
	RequestCount float64 `protobuf:"fixed64,4,opt,name=request_count,json=requestCount,proto3" json:"request_count,omitempty"`
	// Part of RequestCount, for requests going through a proxy.
	ProxiedRequestCount float64 `protobuf:"fixed64,5,opt,name=proxied_request_count,json=proxiedRequestCount,proto3" json:"proxied_request_count,omitempty"`
	// Process uptime in seconds.
	ProcessUptime float64 `protobuf:"fixed64,6,opt,name=process_uptime,json=processUptime,proto3" json:"process_uptime,omitempty"`
	// Time/date that the stat was generated in seconds since
	// 1970-01-01 00:00:00.000 UTC.
	Timestamp int64 `protobuf:"varint,7,opt,name=timestamp,proto3" json:"timestamp,omitempty"`
}

Stat defines a single measurement at a point in time.

func (*Stat) Descriptor added in v0.16.0

func (*Stat) Descriptor() ([]byte, []int)

func (*Stat) GetAverageConcurrentRequests added in v0.16.0

func (m *Stat) GetAverageConcurrentRequests() float64

func (*Stat) GetAverageProxiedConcurrentRequests added in v0.16.0

func (m *Stat) GetAverageProxiedConcurrentRequests() float64

func (*Stat) GetPodName added in v0.16.0

func (m *Stat) GetPodName() string

func (*Stat) GetProcessUptime added in v0.16.0

func (m *Stat) GetProcessUptime() float64

func (*Stat) GetProxiedRequestCount added in v0.16.0

func (m *Stat) GetProxiedRequestCount() float64

func (*Stat) GetRequestCount added in v0.16.0

func (m *Stat) GetRequestCount() float64

func (*Stat) GetTimestamp added in v0.19.0

func (m *Stat) GetTimestamp() int64

func (*Stat) Marshal added in v0.16.0

func (m *Stat) Marshal() (dAtA []byte, err error)

func (*Stat) MarshalTo added in v0.16.0

func (m *Stat) MarshalTo(dAtA []byte) (int, error)

func (*Stat) MarshalToSizedBuffer added in v0.16.0

func (m *Stat) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*Stat) ProtoMessage added in v0.16.0

func (*Stat) ProtoMessage()

func (*Stat) Reset added in v0.16.0

func (m *Stat) Reset()

func (*Stat) Size added in v0.16.0

func (m *Stat) Size() (n int)

func (*Stat) String added in v0.16.0

func (m *Stat) String() string

func (*Stat) Unmarshal added in v0.16.0

func (m *Stat) Unmarshal(dAtA []byte) error

func (*Stat) XXX_DiscardUnknown added in v0.16.0

func (m *Stat) XXX_DiscardUnknown()

func (*Stat) XXX_Marshal added in v0.16.0

func (m *Stat) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Stat) XXX_Merge added in v0.16.0

func (m *Stat) XXX_Merge(src proto.Message)

func (*Stat) XXX_Size added in v0.16.0

func (m *Stat) XXX_Size() int

func (*Stat) XXX_Unmarshal added in v0.16.0

func (m *Stat) XXX_Unmarshal(b []byte) error

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.

func (StatMessage) ToWireStatMessage added in v0.17.0

func (sm StatMessage) ToWireStatMessage() *WireStatMessage

ToWireStatMessage converts the StatMessage to a WireStatMessage.

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

func NewStatsScraper added in v0.15.0

func NewStatsScraper(metric *autoscalingv1alpha1.Metric, revisionName string, podAccessor resources.PodAccessor,
	usePassthroughLb bool, meshMode netcfg.MeshCompatibilityMode, logger *zap.SugaredLogger) StatsScraper

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

type StatsScraperFactory

type StatsScraperFactory func(*autoscalingv1alpha1.Metric, *zap.SugaredLogger) (StatsScraper, error)

StatsScraperFactory creates a StatsScraper for a given Metric.

type WireStatMessage added in v0.17.0

type WireStatMessage struct {
	// Namespace is the namespace of the entity the stat belongs to.
	Namespace string `protobuf:"bytes,1,opt,name=namespace,proto3" json:"namespace,omitempty"`
	// Name is the name of the entity the stat belongs to.
	Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"`
	// Stat are the actual metrics being sent.
	Stat *Stat `protobuf:"bytes,3,opt,name=stat,proto3" json:"stat,omitempty"`
}

WireStatMessage is a copy of the StatMessage Golang type, exploding the fields of `types.NamespacedName` to make it compatible with protobufs.

func (*WireStatMessage) Descriptor added in v0.17.0

func (*WireStatMessage) Descriptor() ([]byte, []int)

func (*WireStatMessage) GetName added in v0.17.0

func (m *WireStatMessage) GetName() string

func (*WireStatMessage) GetNamespace added in v0.17.0

func (m *WireStatMessage) GetNamespace() string

func (*WireStatMessage) GetStat added in v0.17.0

func (m *WireStatMessage) GetStat() *Stat

func (*WireStatMessage) Marshal added in v0.17.0

func (m *WireStatMessage) Marshal() (dAtA []byte, err error)

func (*WireStatMessage) MarshalTo added in v0.17.0

func (m *WireStatMessage) MarshalTo(dAtA []byte) (int, error)

func (*WireStatMessage) MarshalToSizedBuffer added in v0.17.0

func (m *WireStatMessage) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*WireStatMessage) ProtoMessage added in v0.17.0

func (*WireStatMessage) ProtoMessage()

func (*WireStatMessage) Reset added in v0.17.0

func (m *WireStatMessage) Reset()

func (*WireStatMessage) Size added in v0.17.0

func (m *WireStatMessage) Size() (n int)

func (*WireStatMessage) String added in v0.17.0

func (m *WireStatMessage) String() string

func (WireStatMessage) ToStatMessage added in v0.17.0

func (wsm WireStatMessage) ToStatMessage() StatMessage

ToStatMessage converts the WireStatMessage to a StatMessage. Nil-checks must have been done before calling this.

func (*WireStatMessage) Unmarshal added in v0.17.0

func (m *WireStatMessage) Unmarshal(dAtA []byte) error

func (*WireStatMessage) XXX_DiscardUnknown added in v0.17.0

func (m *WireStatMessage) XXX_DiscardUnknown()

func (*WireStatMessage) XXX_Marshal added in v0.17.0

func (m *WireStatMessage) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*WireStatMessage) XXX_Merge added in v0.17.0

func (m *WireStatMessage) XXX_Merge(src proto.Message)

func (*WireStatMessage) XXX_Size added in v0.17.0

func (m *WireStatMessage) XXX_Size() int

func (*WireStatMessage) XXX_Unmarshal added in v0.17.0

func (m *WireStatMessage) XXX_Unmarshal(b []byte) error

type WireStatMessages added in v0.17.0

type WireStatMessages struct {
	// Messages is a list of WireStatMessages.
	Messages []*WireStatMessage `protobuf:"bytes,1,rep,name=messages,proto3" json:"messages,omitempty"`
}

WireStatMessages is a wrapper to send multiple WireStatMessages at once.

func ToWireStatMessages added in v0.17.0

func ToWireStatMessages(sms []StatMessage) WireStatMessages

ToWireStatMessages converts the given slice of StatMessages to a WireStatMessages struct, ready to be sent off.

func (*WireStatMessages) Descriptor added in v0.17.0

func (*WireStatMessages) Descriptor() ([]byte, []int)

func (*WireStatMessages) GetMessages added in v0.17.0

func (m *WireStatMessages) GetMessages() []*WireStatMessage

func (*WireStatMessages) Marshal added in v0.17.0

func (m *WireStatMessages) Marshal() (dAtA []byte, err error)

func (*WireStatMessages) MarshalTo added in v0.17.0

func (m *WireStatMessages) MarshalTo(dAtA []byte) (int, error)

func (*WireStatMessages) MarshalToSizedBuffer added in v0.17.0

func (m *WireStatMessages) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*WireStatMessages) ProtoMessage added in v0.17.0

func (*WireStatMessages) ProtoMessage()

func (*WireStatMessages) Reset added in v0.17.0

func (m *WireStatMessages) Reset()

func (*WireStatMessages) Size added in v0.17.0

func (m *WireStatMessages) Size() (n int)

func (*WireStatMessages) String added in v0.17.0

func (m *WireStatMessages) String() string

func (*WireStatMessages) Unmarshal added in v0.17.0

func (m *WireStatMessages) Unmarshal(dAtA []byte) error

func (*WireStatMessages) XXX_DiscardUnknown added in v0.17.0

func (m *WireStatMessages) XXX_DiscardUnknown()

func (*WireStatMessages) XXX_Marshal added in v0.17.0

func (m *WireStatMessages) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*WireStatMessages) XXX_Merge added in v0.17.0

func (m *WireStatMessages) XXX_Merge(src proto.Message)

func (*WireStatMessages) XXX_Size added in v0.17.0

func (m *WireStatMessages) XXX_Size() int

func (*WireStatMessages) XXX_Unmarshal added in v0.17.0

func (m *WireStatMessages) XXX_Unmarshal(b []byte) error

Jump to

Keyboard shortcuts

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