metrics

package
v0.3.25 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2019 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const APIVersion = "metrics.smi-spec.io/v1alpha1"

Variables

View Source
var AvailableKinds = map[string]*metav1.APIResource{
	"Deployment": {
		Name:       "deployments",
		Namespaced: true,
		Kind:       "TrafficMetrics",
		Verbs: []string{
			"get",
			"list",
		},
	},
	"Pod": {
		Name:       "pods",
		Namespaced: true,
		Kind:       "TrafficMetrics",
		Verbs: []string{
			"get",
			"list",
		},
	},
	"Daemonset": {
		Name:       "daemonsets",
		Namespaced: true,
		Kind:       "TrafficMetrics",
		Verbs: []string{
			"get",
			"list",
		},
	},
	"Statefulset": {
		Name:       "statefulsets",
		Namespaced: true,
		Kind:       "TrafficMetrics",
		Verbs: []string{
			"get",
			"list",
		},
	},
	"Namespace": {
		Name:       "namespaces",
		Namespaced: false,
		Kind:       "TrafficMetrics",
		Verbs: []string{
			"get",
			"list",
		},
	},
}
View Source
var AvailableMetrics = []*Metric{
	{
		Name:  "p99_response_latency",
		Unit:  MilliSeconds,
		Value: apiresource.NewQuantity(0, apiresource.DecimalSI),
	},
	{
		Name:  "p90_response_latency",
		Unit:  MilliSeconds,
		Value: apiresource.NewQuantity(0, apiresource.DecimalSI),
	},
	{
		Name:  "p50_response_latency",
		Unit:  MilliSeconds,
		Value: apiresource.NewQuantity(0, apiresource.DecimalSI),
	},
	{
		Name:  "success_count",
		Value: apiresource.NewQuantity(0, apiresource.DecimalSI),
	},
	{
		Name:  "failure_count",
		Value: apiresource.NewQuantity(0, apiresource.DecimalSI),
	},
}

AvailableMetrics are a list of the possible metrics that can be returned

Functions

This section is empty.

Types

type Direction

type Direction string

Direction defines whether an edge is sending traffic to a resource or receiving traffic from a resource.

const (
	// To is used when an edge is sending traffic to a resource
	To Direction = "to"
	// From is used when an edge is receiving traffic from a resource
	From Direction = "from"
)

type Edge

type Edge struct {
	Direction Direction           `json:"direction"`
	Resource  *v1.ObjectReference `json:"resource"`
}

Edge describes the other resource that metrics are associated with

func (*Edge) String

func (e *Edge) String() string

String returns a formatted string representation of this struct

type Interval

type Interval struct {
	Timestamp metav1.Time     `json:"timestamp"`
	Window    metav1.Duration `json:"window"`
}

Interval defines the time interval from which metrics were collected

func NewInterval

func NewInterval() *Interval

func (*Interval) String

func (i *Interval) String() string

String returns a formatted string representation of this struct

type Metric

type Metric struct {
	Name string `json:"name"`

	Unit  Unit                  `json:"unit,omitempty"`
	Value *apiresource.Quantity `json:"value"`
}

Metric describes a name and value for specific metrics

func (*Metric) Set

func (m *Metric) Set(val float64)

Set will set the value correctly

func (*Metric) String

func (m *Metric) String() string

String returns a formatted string representation of this struct

type TrafficMetrics

type TrafficMetrics struct {
	metav1.TypeMeta   `json:",inline"`
	metav1.ObjectMeta `json:"metadata,omitempty"`

	*Interval `json:",inline"`

	Resource *v1.ObjectReference `json:"resource"`
	Edge     *Edge               `json:"edge"`
	Metrics  []*Metric           `json:"metrics"`
}

TrafficMetrics provide the metrics for a specific resource

func NewTrafficMetrics

func NewTrafficMetrics(obj, edge *v1.ObjectReference) *TrafficMetrics

NewTrafficMetrics constructs a TrafficMetrics with all the defaults

func (*TrafficMetrics) Get

func (t *TrafficMetrics) Get(name string) *Metric

Get returns a metric associated with a name

func (*TrafficMetrics) String

func (t *TrafficMetrics) String() string

String returns a formatted string representation of this struct

type TrafficMetricsList

type TrafficMetricsList struct {
	metav1.TypeMeta `json:",inline"`
	metav1.ListMeta `json:"metadata,omitempty"`

	Resource *v1.ObjectReference `json:"resource"`

	Items []*TrafficMetrics `json:"items"`
}

TrafficMetricsList provides a list of resources associated with a specific reference

func NewTrafficMetricsList

func NewTrafficMetricsList(
	obj *v1.ObjectReference, edges bool) *TrafficMetricsList

NewTrafficMetricsList constructs a new object with defaults already configured

func (*TrafficMetricsList) Get

func (lst *TrafficMetricsList) Get(
	obj, edge *v1.ObjectReference) *TrafficMetrics

Get will get the item that is associated with the object reference or create a default if it doesn't already exist.

func (*TrafficMetricsList) String

func (lst *TrafficMetricsList) String() string

String returns a formatted string representation of this struct

type Unit

type Unit string

Unit is associated with metrics and defines what unit the metric is using

const MilliSeconds Unit = "ms"

MilliSeconds is a time unit

Jump to

Keyboard shortcuts

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