monitoring

package
v0.20.1 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2023 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EventReasonNodeIpUpdate   = "NodeIpUpdate"
	EventReasonNodePortUpdate = "NodePortUpdate"
)

Variables

This section is empty.

Functions

func MustRegister added in v0.5.0

func MustRegister(metrics ...Metric)

MustRegister is a helper function that will ensure that the provided Metrics are registered. If a metric fails to register, this method will panic.

func RegisterRecordHook added in v0.5.0

func RegisterRecordHook(name string, h RecordHook)

RegisterRecordHook adds a RecordHook for a given measure.

Types

type DerivedMetric added in v0.5.0

type DerivedMetric interface {
	// Name returns the name value of a DerivedMetric.
	Name() string

	// Register handles any required setup to ensure metric export.
	Register() error
}

DerivedMetrics can be used to supply values that dynamically derive from internal state, but are not updated based on any specific event. Their value will be calculated based on a value func that executes when the metrics are exported.

At the moment, only a Gauge type is supported.

func NewDerivedGauge added in v0.5.0

func NewDerivedGauge(name, description string, valueFn func() float64) DerivedMetric

NewDerivedGauge creates a new Metric with an aggregation type of LastValue that generates the value dynamically according to the provided function. This can be used for values based on querying some state within a system (when event-driven recording is not appropriate). NOTE: Labels not currently supported.

type Event

type Event struct {
	Object            runtime.Object
	RelatedObject     runtime.Object
	EventType         EventType
	Reason            string
	Message           string
	Action            string
	ReportingInstance string
}

type EventRecorder

type EventRecorder struct {
	Client    client.Client
	Logger    *zap.SugaredLogger
	Scheme    *runtime.Scheme
	Version   string
	Cluster   string
	Tenant    string
	Slice     string
	Namespace string
	Component string
}

func (*EventRecorder) Copy

func (er *EventRecorder) Copy() *EventRecorder

func (*EventRecorder) RecordEvent

func (er *EventRecorder) RecordEvent(ctx context.Context, e *Event) error

RecordEvent raises a new event with the given fields TODO: events caching and aggregation

func (*EventRecorder) WithNamespace

func (er *EventRecorder) WithNamespace(ns string) *EventRecorder

WithNamespace returns a new recorder with added namespace name If namespace is not provided, recorder will use the object namespace

func (*EventRecorder) WithSlice

func (er *EventRecorder) WithSlice(slice string) *EventRecorder

WithSlice returns a new recorder with added slice name for raising events

type EventType

type EventType string
var (
	EventTypeWarning EventType = "Warning"
	EventTypeNormal  EventType = "Normal"
)

type Label added in v0.5.0

type Label tag.Key

A Label provides a named dimension for a Metric.

func MustCreateLabel added in v0.5.0

func MustCreateLabel(key string) Label

MustCreateLabel will attempt to create a new Label. If creation fails, then this method will panic.

func (Label) Value added in v0.5.0

func (l Label) Value(value string) LabelValue

Value creates a new LabelValue for the Label.

type LabelValue added in v0.5.0

type LabelValue tag.Mutator

A LabelValue represents a Label with a specific value. It is used to record values for a Metric.

type Metric added in v0.5.0

type Metric interface {
	// Increment records a value of 1 for the current measure. For Sums,
	// this is equivalent to adding 1 to the current value. For Gauges,
	// this is equivalent to setting the value to 1. For Distributions,
	// this is equivalent to making an observation of value 1.
	Increment()

	// Decrement records a value of -1 for the current measure. For Sums,
	// this is equivalent to subtracting -1 to the current value. For Gauges,
	// this is equivalent to setting the value to -1. For Distributions,
	// this is equivalent to making an observation of value -1.
	Decrement()

	// Name returns the name value of a Metric.
	Name() string

	// Record makes an observation of the provided value for the given measure.
	Record(value float64)

	// RecordInt makes an observation of the provided value for the measure.
	RecordInt(value int64)
	// With creates a new Metric, with the LabelValues provided. This allows creating
	// a set of pre-dimensioned data for recording purposes. This is primarily used
	// for documentation and convenience. Metrics created with this method do not need
	// to be registered (they share the registration of their parent Metric).
	With(labelValues ...LabelValue) Metric

	// Register configures the Metric for export. It MUST be called before collection
	// of values for the Metric. An error will be returned if registration fails.
	Register() error
}

A Metric collects numerical observations.

func NewDistribution added in v0.5.0

func NewDistribution(name, description string, bounds []float64, opts ...Options) Metric

NewDistribution creates a new Metric with an aggregation type of Distribution. This means that the data collected by the Metric will be collected and exported as a histogram, with the specified bounds.

func NewGauge added in v0.5.0

func NewGauge(name, description string, opts ...Options) Metric

NewGauge creates a new Metric with an aggregation type of LastValue. That means that data collected by the new Metric will export only the last recorded value.

func NewSum added in v0.5.0

func NewSum(name, description string, opts ...Options) Metric

NewSum creates a new Metric with an aggregation type of Sum (the values will be cumulative). That means that data collected by the new Metric will be summed before export.

type Options added in v0.5.0

type Options func(*options)

Options encode changes to the options passed to a Metric at creation time.

func WithInt64Values added in v0.5.0

func WithInt64Values() Options

WithInt64Values provides configuration options for a new Metric, indicating that recorded values will be saved as int64 values. Any float64 values recorded will converted to int64s via math.Floor-based conversion.

func WithLabels added in v0.5.0

func WithLabels(labels ...Label) Options

WithLabels provides configuration options for a new Metric, providing the expected dimensions for data collection for that Metric.

func WithUnit added in v0.5.0

func WithUnit(unit Unit) Options

WithUnit provides configuration options for a new Metric, providing unit of measure information for a new Metric.

type RecordHook added in v0.5.0

type RecordHook interface {
	OnRecordFloat64Measure(f *stats.Float64Measure, tags []tag.Mutator, value float64)
	OnRecordInt64Measure(i *stats.Int64Measure, tags []tag.Mutator, value int64)
}

RecordHook has a callback function which a measure is recorded.

type Unit added in v0.5.0

type Unit string

Unit encodes the standard name for describing the quantity measured by a Metric (if applicable).

const (
	None         Unit = "1"
	Bytes        Unit = "By"
	Seconds      Unit = "s"
	Milliseconds Unit = "ms"
)

Predefined units for use with the monitoring package.

Jump to

Keyboard shortcuts

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