internal

package
v0.8.1 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2024 License: Apache-2.0 Imports: 30 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type HPACallback

type HPACallback func(ctx context.Context, ms []HPAMetric)

type HPADiscoverer

type HPADiscoverer struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func NewHPADiscoverer

func NewHPADiscoverer(client kubernetes.Interface, updateCallback HPACallback, deleteCallback HPACallback, mapper apimeta.RESTMapper) *HPADiscoverer

func (*HPADiscoverer) Discover

func (d *HPADiscoverer) Discover(ctx context.Context)

func (*HPADiscoverer) InternalMetrics

func (d *HPADiscoverer) InternalMetrics() []*datapoint.Datapoint

type HPAMetric

type HPAMetric struct {
	// UID of the HPA that is associated with this metric
	UID types.UID
	// The type of K8s resource that the metric pertains to
	GroupResource schema.GroupResource
	// Which namespace the metric pertains to, will be blank for external
	// metrics
	Namespace string
	// The name of the metric in the HPA
	Metric string

	// For external metrics, the SignalFlow program specified in the HPA
	// annotations.
	Program string
	// Selectors for the metrics themselves.
	MetricSelector labels.Selector
	// The selector on the HPA target resource to select pods.  This is what
	// will come in the request for metrics from K8s.
	PodSelector labels.Selector
	// For specific Object custom metrics, the name of the target resource.
	// The type of the resource is specified in the GroupResource field.
	TargetName string
	// The "scaleTargetRef" of the HPA, i.e. the thing that the HPA is
	// "attached" to that is being scaled up or down in response to the metrics.
	HPAResource autoscaling.CrossVersionObjectReference
}

HPAMetric is used to provide a standard definition of a metric that can be used to link together metrics defined in the HPAs and those requested by the K8s autoscaler via API requests.

func (*HPAMetric) IsExternal

func (m *HPAMetric) IsExternal() bool

IsExternal returns true if this metric is an external (not custom) metric.

func (*HPAMetric) Key

func (m *HPAMetric) Key() string

Key is like a hash function except it just makes a big string

func (*HPAMetric) SignalFlowProgram

func (m *HPAMetric) SignalFlowProgram() string

type MetricSnapshot

type MetricSnapshot map[idtool.ID]*TSIDValueMetadata

MetricSnapshot represents the latest state of received metric data from a SignalFlow job.

type Registry

type Registry struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewRegistry

func NewRegistry(jobRunner *SignalFlowJobRunner) *Registry

func (*Registry) AllCustomMetrics

func (r *Registry) AllCustomMetrics() []provider.CustomMetricInfo

func (*Registry) AllExternalMetrics

func (r *Registry) AllExternalMetrics() []provider.ExternalMetricInfo

func (*Registry) HPAMetricMatchingKey

func (r *Registry) HPAMetricMatchingKey(m *HPAMetric) *HPAMetric

func (*Registry) HandleHPADeleted

func (r *Registry) HandleHPADeleted(ctx context.Context, deletedMetrics []HPAMetric)

func (*Registry) HandleHPAUpdated

func (r *Registry) HandleHPAUpdated(ctx context.Context, updatedMetrics []HPAMetric)

func (*Registry) InternalMetrics

func (r *Registry) InternalMetrics() []*datapoint.Datapoint

func (*Registry) LatestSnapshot

func (r *Registry) LatestSnapshot(m *HPAMetric) (MetricSnapshot, error)

type SignalFlowJobRunner

type SignalFlowJobRunner struct {
	CleanupOldTSIDsInterval time.Duration
	MetadataTimeout         time.Duration
	MinimumTimeseriesExpiry time.Duration

	TotalJobsStarted int64
	TotalJobsStopped int64
	TotalJobsErrored int64
	// contains filtered or unexported fields
}

SignalFlowJobRunner manages SignalFlow jobs.

func NewSignalFlowJobRunner

func NewSignalFlowJobRunner(client *signalflow.Client) *SignalFlowJobRunner

func (*SignalFlowJobRunner) InternalMetrics

func (jr *SignalFlowJobRunner) InternalMetrics() []*datapoint.Datapoint

func (*SignalFlowJobRunner) LatestSnapshot

func (jr *SignalFlowJobRunner) LatestSnapshot(m *HPAMetric) (MetricSnapshot, error)

func (*SignalFlowJobRunner) ReplaceOrStartJob

func (jr *SignalFlowJobRunner) ReplaceOrStartJob(ctx context.Context, program string) error

func (*SignalFlowJobRunner) Run

func (jr *SignalFlowJobRunner) Run(ctx context.Context)

Run does everything in a single loop to prevent heavy churn on a mutex when there are a lot of jobs running and updating values, and also avoids the possiblity of data races. This trades off mutexes for channels.

func (*SignalFlowJobRunner) StopJob

func (jr *SignalFlowJobRunner) StopJob(program string)

type SignalFxProvider

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

SignalFxProvider maps K8s metrics to SignalFlow job output

func NewSignalFxProvider

func NewSignalFxProvider(registry *Registry, mapper apimeta.RESTMapper) *SignalFxProvider

NewSignalFxProvider returns an instance of SignalFxProvider

func (*SignalFxProvider) GetExternalMetric

func (p *SignalFxProvider) GetExternalMetric(ctx context.Context, namespace string, metricSelector labels.Selector, info provider.ExternalMetricInfo) (*external_metrics.ExternalMetricValueList, error)

func (*SignalFxProvider) GetMetricByName

func (*SignalFxProvider) GetMetricBySelector

func (p *SignalFxProvider) GetMetricBySelector(ctx context.Context, namespace string, selector labels.Selector, info provider.CustomMetricInfo, metricSelector labels.Selector) (*custom_metrics.MetricValueList, error)

func (*SignalFxProvider) InternalMetrics

func (p *SignalFxProvider) InternalMetrics() []*datapoint.Datapoint

func (*SignalFxProvider) ListAllExternalMetrics

func (p *SignalFxProvider) ListAllExternalMetrics() []provider.ExternalMetricInfo

func (*SignalFxProvider) ListAllMetrics

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

type TSIDValueMetadata

type TSIDValueMetadata struct {
	TSID       idtool.ID
	Val        float64
	Metadata   *messages.MetadataProperties
	Timestamp  time.Time
	Resolution time.Duration
}

func (*TSIDValueMetadata) PodName

func (tvm *TSIDValueMetadata) PodName() string

PodNameForTSID returns the pod name that is associated with the given TSID, if any.

Jump to

Keyboard shortcuts

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