data

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2024 License: Apache-2.0 Imports: 12 Imported by: 8

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AppendSupportedMetricObject

func AppendSupportedMetricObject(supported map[string]schema.GroupVersionResource)

func GetSupportedMetricObject

func GetSupportedMetricObject() map[string]schema.GroupVersionResource

func MergeInternalMetricList

func MergeInternalMetricList(metricName string, metricLists ...[]types.Metric) []types.Metric

MergeInternalMetricList merges internal metric lists and sort them for series: if the same timestamp appears in different list, randomly choose one item. for aggregated: we will just skip the duplicated items

Types

type CachedMetric

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

CachedMetric stores all metricItems in an organized way. the aggregation logic will be performed in this package.

func NewCachedMetric

func NewCachedMetric(metricsEmitter metrics.MetricEmitter, storeType ObjectMetricStoreType) *CachedMetric

func (*CachedMetric) AddSeriesMetric added in v0.4.0

func (c *CachedMetric) AddSeriesMetric(sList ...types.Metric) error

func (*CachedMetric) GC

func (c *CachedMetric) GC(expiredTime time.Time)

func (*CachedMetric) GetAllMetricsInNamespace added in v0.4.0

func (c *CachedMetric) GetAllMetricsInNamespace(namespace string) []types.Metric

GetAllMetricsInNamespace & GetAllMetricsInNamespaceWithLimit may be too time-consuming, so we should ensure that client falls into this functions as less frequent as possible.

func (*CachedMetric) GetMetric

func (c *CachedMetric) GetMetric(namespace, metricName string, objName string, objectMetaList []types.ObjectMetaImp, usingObjectMetaList bool, gr *schema.GroupResource, metricSelector labels.Selector, latest bool) ([]types.Metric, bool, error)

func (*CachedMetric) ListAllMetricMeta

func (c *CachedMetric) ListAllMetricMeta(withObject bool) []types.MetricMeta

ListAllMetricMeta returns all metric meta with a flattened slice

func (*CachedMetric) ListAllMetricNames

func (c *CachedMetric) ListAllMetricNames() []string

ListAllMetricNames returns all metric with a flattened slice, but only contain names

func (*CachedMetric) Purge added in v0.4.0

func (c *CachedMetric) Purge()

type CustomMetricLabelKey

type CustomMetricLabelKey string
const (
	CustomMetricLabelKeyNamespace      CustomMetricLabelKey = "namespace"
	CustomMetricLabelKeyObject         CustomMetricLabelKey = "object"
	CustomMetricLabelKeyObjectName     CustomMetricLabelKey = "object_name"
	CustomMetricLabelKeyTimestamp      CustomMetricLabelKey = "timestamp"
	CustomMetricLabelSelectorPrefixKey CustomMetricLabelKey = "selector_"
)

those const variables define the standard semantics of metric labels

CustomMetricLabelKeyNamespace defines the namespace; CustomMetricLabelKeyObject defines the standard kubernetes objects; CustomMetricLabelKeyObjectName defines the name of kubernetes objects; CustomMetricLabelKeyTimestamp defines the timestamp of this metric; CustomMetricLabelSelectorPrefixKey nominates those labels that should be used as selector;

type MetricData

type MetricData struct {
	Data      float64 `json:"data,omitempty"`
	Timestamp int64   `json:"timestamp,omitempty"`
}

type MetricSeries

type MetricSeries struct {
	Name   string            `json:"name,omitempty"`
	Labels map[string]string `json:"labels,omitempty"`
	Series []*MetricData     `json:"series,omitempty"`
}

type ObjectMetricStore added in v0.4.0

type ObjectMetricStore interface {
	Add(objectMeta types.ObjectMetaImp) error
	ObjectExists(objectMeta types.ObjectMetaImp) (bool, error)
	GetInternalMetricImp(objectMeta types.ObjectMetaImp) (*internal.MetricImp, error)

	// Iterate is read only, please do not perform any write operation like add/delete to this object
	Iterate(f func(internalMetric *internal.MetricImp))
	Purge()
	Len() int
}

func NewBucketObjectMetricStore added in v0.4.0

func NewBucketObjectMetricStore(bucketSize int, metricMeta types.MetricMetaImp) ObjectMetricStore

func NewSimpleObjectMetricStore added in v0.4.0

func NewSimpleObjectMetricStore(metricMeta types.MetricMetaImp) ObjectMetricStore

type ObjectMetricStoreType added in v0.4.0

type ObjectMetricStoreType string
const (
	ObjectMetricStoreTypeSimple ObjectMetricStoreType = "simple"
	ObjectMetricStoreTypeBucket ObjectMetricStoreType = "bucket"
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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