Documentation ¶
Index ¶
- type HPACallback
- type HPADiscoverer
- type HPAMetric
- type MetricSnapshot
- type Registry
- func (r *Registry) AllCustomMetrics() []provider.CustomMetricInfo
- func (r *Registry) AllExternalMetrics() []provider.ExternalMetricInfo
- func (r *Registry) HPAMetricMatchingKey(m *HPAMetric) *HPAMetric
- func (r *Registry) HandleHPADeleted(ctx context.Context, deletedMetrics []HPAMetric)
- func (r *Registry) HandleHPAUpdated(ctx context.Context, updatedMetrics []HPAMetric)
- func (r *Registry) InternalMetrics() []*datapoint.Datapoint
- func (r *Registry) LatestSnapshot(m *HPAMetric) (MetricSnapshot, error)
- type SignalFlowJobRunner
- func (jr *SignalFlowJobRunner) InternalMetrics() []*datapoint.Datapoint
- func (jr *SignalFlowJobRunner) LatestSnapshot(m *HPAMetric) (MetricSnapshot, error)
- func (jr *SignalFlowJobRunner) ReplaceOrStartJob(ctx context.Context, program string) error
- func (jr *SignalFlowJobRunner) Run(ctx context.Context)
- func (jr *SignalFlowJobRunner) StopJob(program string)
- type SignalFxProvider
- func (p *SignalFxProvider) GetExternalMetric(ctx context.Context, namespace string, metricSelector labels.Selector, ...) (*external_metrics.ExternalMetricValueList, error)
- func (p *SignalFxProvider) GetMetricByName(ctx context.Context, name types.NamespacedName, info provider.CustomMetricInfo, ...) (*custom_metrics.MetricValue, error)
- func (p *SignalFxProvider) GetMetricBySelector(ctx context.Context, namespace string, selector labels.Selector, ...) (*custom_metrics.MetricValueList, error)
- func (p *SignalFxProvider) InternalMetrics() []*datapoint.Datapoint
- func (p *SignalFxProvider) ListAllExternalMetrics() []provider.ExternalMetricInfo
- func (p *SignalFxProvider) ListAllMetrics() []provider.CustomMetricInfo
- type TSIDValueMetadata
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type HPACallback ¶
type HPADiscoverer ¶
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 ¶
IsExternal returns true if this metric is an external (not custom) metric.
func (*HPAMetric) SignalFlowProgram ¶
type MetricSnapshot ¶
type MetricSnapshot map[idtool.ID]*TSIDValueMetadata
MetricSnapshot represents the latest state of received metric data from a SignalFlow job.
type Registry ¶
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 (*Registry) HandleHPADeleted ¶
func (*Registry) HandleHPAUpdated ¶
func (*Registry) InternalMetrics ¶
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 (p *SignalFxProvider) GetMetricByName(ctx context.Context, name types.NamespacedName, info provider.CustomMetricInfo, metricSelector labels.Selector) (*custom_metrics.MetricValue, error)
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.