metrics

package
v1.6.2 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2024 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package metrics is for metrics, used in CSI

Index

Constants

View Source
const DbgMetricHoldTime = 3 * 60

DbgMetricHoldTime is Dbg metric hold time, after that, Dbg metric will be cleaned up in case more and more metrics exists.

View Source
const EventReasonFailedScheduling = "FailedScheduling"

EventReasonFailedScheduling is the keyword to find out failed scheduling event, which is useful to calculate scheduling metrics.

View Source
const EventReasonKilling = "Killing"

EventReasonKilling is the delimiter keyword used to distinguish if pod event is for current pod, not for same name pod already killed, which is useful to calculate scheduling metrics.

Variables

View Source
var (
	//nolint
	Branch string
	//nolint
	Revision string
)
View Source
var BuildInfo = prometheus.NewGaugeFunc(
	prometheus.GaugeOpts{
		Name:        "build_info",
		Help:        "A metric with a constant '1' value labeled by version, revision, branch",
		ConstLabels: prometheus.Labels{"version": base.PluginVersion, "revision": Revision, "branch": Branch},
	},
	func() float64 { return 1 },
)

BuildInfo used to expose information of the current build

View Source
var ExtendedDefBuckets = []float64{.025, .05, .1, .5, 1, 3, 5, 10, 15, 30, 45, 90, 180}

ExtendedDefBuckets is a default buckets used for csi driver

Functions

This section is empty.

Types

type Counter added in v1.3.0

type Counter interface {
	Collect() prometheus.Collector
	Add(labels prometheus.Labels)
	Clear(label prometheus.Labels)
}

Counter is a common interface for counter metrics

type CounterWithCustomLabels added in v1.3.0

type CounterWithCustomLabels struct {
	CounterVec *prometheus.CounterVec
}

CounterWithCustomLabels is a structure, which encapsulate prometheus CounterVec structure. It used for counts something. also supports additional metrics labels, this can be useful when you want to create metrics with dynamic labels, which prometheus doesn't support in native

func NewCounterWithCustomLabels added in v1.3.0

func NewCounterWithCustomLabels(opts prometheus.CounterOpts, labels ...string) *CounterWithCustomLabels

NewCounterWithCustomLabels initializes CounterWithCustomLabels

func (*CounterWithCustomLabels) Add added in v1.3.0

func (m *CounterWithCustomLabels) Add(labels prometheus.Labels)

Add adds value to metric with specific labels, also support to clear metric by labels

func (*CounterWithCustomLabels) Clear added in v1.3.0

func (m *CounterWithCustomLabels) Clear(labels prometheus.Labels)

Clear clears metric by labels

func (*CounterWithCustomLabels) Collect added in v1.3.0

Collect returns prometheus.Collector slice with internal CounterVec

type MetricWithCustomLabels added in v1.3.0

type MetricWithCustomLabels struct {
	GaugeVec *prometheus.GaugeVec
}

MetricWithCustomLabels is a structure, which encapsulate prometheus GaugeVec structure. It used for evalute duration, it support support dynamic labels to make it easy to distinguish metric data that has same metric name but different label.

func NewMetricsWithCustomLabels added in v1.3.0

func NewMetricsWithCustomLabels(opts prometheus.GaugeOpts, labels ...string) *MetricWithCustomLabels

NewMetricsWithCustomLabels initializes MetricsWithCustomLabels

func (*MetricWithCustomLabels) Clear added in v1.3.0

func (m *MetricWithCustomLabels) Clear(labels prometheus.Labels)

Clear clears metric by labels

func (*MetricWithCustomLabels) Collect added in v1.3.0

Collect returns prometheus.Collector slice with internal GaugeVec

func (*MetricWithCustomLabels) EvaluateDurationForMethod added in v1.3.0

func (m *MetricWithCustomLabels) EvaluateDurationForMethod(method string, labels prometheus.Labels) func()

EvaluateDurationForMethod evaluate duration of the method call with label

func (*MetricWithCustomLabels) EvaluateDurationForType added in v1.3.0

func (m *MetricWithCustomLabels) EvaluateDurationForType(t string, labels prometheus.Labels) func()

EvaluateDurationForType evaluate function call with "type" label

func (*MetricWithCustomLabels) EvaluateDurationWithLabel added in v1.3.0

func (m *MetricWithCustomLabels) EvaluateDurationWithLabel(labels prometheus.Labels) func()

EvaluateDurationWithLabel evaluate duration with label

func (*MetricWithCustomLabels) UpdateValue added in v1.3.0

func (m *MetricWithCustomLabels) UpdateValue(value float64, labels prometheus.Labels, clear bool, clearLabels prometheus.Labels)

UpdateValue update value of metric with specific labels, also support to clear metric by labels

type Metrics

type Metrics struct {
	OperationsDuration *prometheus.HistogramVec
}

Metrics is a structure, which encapsulate prometheus histogram structure. It used for volume operation metrics

func NewMetrics

func NewMetrics(opts prometheus.HistogramOpts, labels ...string) *Metrics

NewMetrics initializes operations duration metrics

func (*Metrics) Collect

func (m *Metrics) Collect() prometheus.Collector

Collect returns prometheus.Collector slice with OperationsDuration histogram

func (*Metrics) EvaluateDuration

func (m *Metrics) EvaluateDuration(labels prometheus.Labels) func()

EvaluateDuration evaluate duration from start for a given method and put it into histogram Receive prometheus.Labels.

func (*Metrics) EvaluateDurationForMethod

func (m *Metrics) EvaluateDurationForMethod(method string) func()

EvaluateDurationForMethod of the method call

func (*Metrics) EvaluateDurationForType

func (m *Metrics) EvaluateDurationForType(t string) func()

EvaluateDurationForType evaluate function call with "type" label

type Statistic

type Statistic interface {
	Collect() prometheus.Collector
	EvaluateDuration(labels prometheus.Labels) func()
	EvaluateDurationForMethod(method string) func()
	EvaluateDurationForType(t string) func()
}

Statistic is a common interface for histogram metrics

type StatisticWithCustomLabels added in v1.3.0

type StatisticWithCustomLabels interface {
	Collect() prometheus.Collector
	EvaluateDurationWithLabel(labels prometheus.Labels) func()
	EvaluateDurationForMethod(method string, labels prometheus.Labels) func()
	EvaluateDurationForType(t string, labels prometheus.Labels) func()
	UpdateValue(value float64, labels prometheus.Labels, clear bool, clearLabels prometheus.Labels)
	Clear(label prometheus.Labels)
}

StatisticWithCustomLabels is Similar to Statistic but have Custom labels, but StatisticWithCustomLabels supports additional metrics labels, this can be useful when you want to create metrics with dynamic labels, which prometheus doesn't support in native

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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