data

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2023 License: Apache-2.0 Imports: 8 Imported by: 8

Documentation

Index

Constants

This section is empty.

Variables

Functions

func AppendSupportedMetricObject

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

func GenerateMetaTags added in v0.2.0

func GenerateMetaTags(m *MetricMeta, d *ObjectMeta) []metrics.MetricTag

GenerateMetaTags returns tag based on the given meta-info

func GetSupportedMetricObject

func GetSupportedMetricObject() map[string]schema.GroupVersionResource

func Marshal

func Marshal(internalList []*InternalMetric) ([]byte, error)

Types

type CachedMetric

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

CachedMetric stores all metricItems in an organized way;

func NewCachedMetric

func NewCachedMetric(metricsEmitter metrics.MetricEmitter) *CachedMetric

func (*CachedMetric) Add

func (c *CachedMetric) Add(dList ...*InternalMetric)

func (*CachedMetric) GC

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

func (*CachedMetric) GetMetric

func (c *CachedMetric) GetMetric(namespace, metricName string, gr *schema.GroupResource) ([]*InternalMetric, bool)

GetMetric returns the metric matched with the given key

func (*CachedMetric) GetMetricInNamespace

func (c *CachedMetric) GetMetricInNamespace(namespace string) []*InternalMetric

GetMetricInNamespace returns the metric matched with the given Namespace

func (*CachedMetric) GetMetricInNamespaceWithLimit

func (c *CachedMetric) GetMetricInNamespaceWithLimit(namespace string, limit int) []*InternalMetric

func (*CachedMetric) GetMetricWithLimit

func (c *CachedMetric) GetMetricWithLimit(namespace, metricName string, gr *schema.GroupResource, limit int) ([]*InternalMetric, bool)

func (*CachedMetric) ListAllMetric

func (c *CachedMetric) ListAllMetric() []*InternalMetric

ListAllMetric returns all metric with a flattened slice

func (*CachedMetric) ListAllMetricMeta

func (c *CachedMetric) ListAllMetricMeta(withObject bool) []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

type CustomMetricLabelAggregateFunc

type CustomMetricLabelAggregateFunc string
const (
	CustomMetricLabelAggregateFuncMax CustomMetricLabelAggregateFunc = "max"
	CustomMetricLabelAggregateFuncMin CustomMetricLabelAggregateFunc = "min"
	CustomMetricLabelAggregateFuncP99 CustomMetricLabelAggregateFunc = "p99"
	CustomMetricLabelAggregateFuncP90 CustomMetricLabelAggregateFunc = "p90"
	CustomMetricLabelAggregateFuncP50 CustomMetricLabelAggregateFunc = "p50"
	CustomMetricLabelAggregateFuncAvg CustomMetricLabelAggregateFunc = "avg"
	CustomMetricLabelAggregateFuncSum CustomMetricLabelAggregateFunc = "sum"
)

type CustomMetricLabelKey

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

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; CustomMetricLabelAggregatePrefixKey means that we should do aggregations for metric with the same labels;

type InternalMetric

type InternalMetric struct {
	MetricMeta `json:",inline"`
	ObjectMeta `json:",inline"`

	Labels        map[string]string `json:"labels,omitempty"`
	InternalValue []*InternalValue  `json:"internalValue,omitempty"`
}

InternalMetric is used as an internal version of metricItem

func NewInternalMetric

func NewInternalMetric(name string) *InternalMetric

func PackInternalMetricList added in v0.2.0

func PackInternalMetricList(internalLists ...[]*InternalMetric) []*InternalMetric

PackInternalMetricList merges internal metric lists and sort them, if the same timestamp appears in different list (which should happen actually), we will randomly choose one item.

func Unmarshal

func Unmarshal(bytes []byte) ([]*InternalMetric, error)

func (*InternalMetric) AppendMetric

func (a *InternalMetric) AppendMetric(i *InternalValue)

func (*InternalMetric) DeepCopy

func (a *InternalMetric) DeepCopy() *InternalMetric

func (*InternalMetric) DeepCopyWithLimit

func (a *InternalMetric) DeepCopyWithLimit(limit int) *InternalMetric

func (*InternalMetric) GenerateTags added in v0.2.0

func (a *InternalMetric) GenerateTags() []metrics.MetricTag

func (*InternalMetric) GetLabels

func (a *InternalMetric) GetLabels() map[string]string

func (*InternalMetric) GetValues

func (a *InternalMetric) GetValues() []*InternalValue

func (*InternalMetric) Len

func (a *InternalMetric) Len() int

func (*InternalMetric) Less

func (a *InternalMetric) Less(i, j int) bool

func (*InternalMetric) SetLabel

func (a *InternalMetric) SetLabel(key, value string)

func (*InternalMetric) SetObjectNamespace

func (a *InternalMetric) SetObjectNamespace(objectNamespace string)

func (*InternalMetric) String

func (a *InternalMetric) String() string

func (*InternalMetric) Swap

func (a *InternalMetric) Swap(i, j int)

type InternalValue

type InternalValue struct {
	Value     int64 `json:"value,omitempty"`
	Timestamp int64 `json:"timestamp,omitempty"`
}

func NewInternalValue

func NewInternalValue(value int64, timestamp int64) *InternalValue

func (*InternalValue) DeepCopy

func (i *InternalValue) DeepCopy() *InternalValue

func (*InternalValue) GetTimestamp

func (i *InternalValue) GetTimestamp() int64

func (*InternalValue) GetValue

func (i *InternalValue) GetValue() int64

type MetricData

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

type MetricMeta

type MetricMeta struct {
	Name       string `json:"name,omitempty"`
	Namespaced bool   `json:"namespaced,omitempty"`
	ObjectKind string `json:"objectKind,omitempty"`
}

func PackMetricMetaList added in v0.2.0

func PackMetricMetaList(metricMetaLists ...[]MetricMeta) []MetricMeta

PackMetricMetaList merges MetricMeta lists and removes duplicates

func (*MetricMeta) GetName

func (m *MetricMeta) GetName() string

func (*MetricMeta) GetNamespaced

func (m *MetricMeta) GetNamespaced() bool

func (*MetricMeta) GetObjectKind

func (m *MetricMeta) GetObjectKind() string

func (*MetricMeta) SetName

func (m *MetricMeta) SetName(name string)

func (*MetricMeta) SetNamespaced

func (m *MetricMeta) SetNamespaced(namespaced bool)

func (*MetricMeta) SetObjectKind

func (m *MetricMeta) SetObjectKind(objectKind string)

type MetricSeries

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

type ObjectMeta

type ObjectMeta struct {
	ObjectNamespace string `json:"objectNamespace,omitempty"`
	ObjectName      string `json:"objectName,omitempty"`
}

func (*ObjectMeta) GetObjectName

func (m *ObjectMeta) GetObjectName() string

func (*ObjectMeta) GetObjectNamespace

func (m *ObjectMeta) GetObjectNamespace() string

func (*ObjectMeta) SetObjectName

func (m *ObjectMeta) SetObjectName(objectName string)

func (*ObjectMeta) SetObjectNamespace

func (m *ObjectMeta) SetObjectNamespace(objectNamespace string)

Jump to

Keyboard shortcuts

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