metrics

package
v0.0.0-...-d88c8b5 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2021 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterBuildInfo

func RegisterBuildInfo(r KubeRegistry)

RegisterBuildInfo registers the build and version info in a metadata metric in prometheus

func RegisterProcessStartTime

func RegisterProcessStartTime(registrationFunc func(prometheus.Collector) error) error

RegisterProcessStartTime registers the process_start_time_seconds to a prometheus registry. This metric needs to be included to ensure counter data fidelity.

func SetShowHidden

func SetShowHidden()

SetShowHidden will enable showing hidden metrics. This will no-opt after the initial call

func ShouldShowHidden

func ShouldShowHidden() bool

ShouldShowHidden returns whether showing hidden deprecated metrics is enabled. While the primary usecase for this is internal (to determine registration behavior) this can also be used to introspect

Types

type Collector

type Collector interface {
	Describe(chan<- *prometheus.Desc)
	Collect(chan<- prometheus.Metric)
}

Collector defines a subset of prometheus.Collector interface methods

type Counter

type Counter struct {
	CounterMetric
	*CounterOpts
	// contains filtered or unexported fields
}

Counter is our internal representation for our wrapping struct around prometheus counters. Counter implements both kubeCollector and CounterMetric.

func NewCounter

func NewCounter(opts *CounterOpts) *Counter

NewCounter returns an object which satisfies the kubeCollector and CounterMetric interfaces. However, the object returned will not measure anything unless the collector is first registered, since the metric is lazily instantiated.

func (*Counter) Collect

func (c *Counter) Collect(ch chan<- prometheus.Metric)

func (*Counter) Create

func (r *Counter) Create(version *semver.Version) bool

Create forces the initialization of metric which has been deferred until the point at which this method is invoked. This method will determine whether the metric is deprecated or hidden, no-opting if the metric should be considered hidden. Furthermore, this function no-opts and returns true if metric is already created.

func (*Counter) DeprecatedVersion

func (c *Counter) DeprecatedVersion() *semver.Version

DeprecatedVersion returns a pointer to the Version or nil

func (*Counter) Describe

func (c *Counter) Describe(ch chan<- *prometheus.Desc)

func (*Counter) IsCreated

func (r *Counter) IsCreated() bool

func (*Counter) IsDeprecated

func (r *Counter) IsDeprecated() bool

func (*Counter) IsHidden

func (r *Counter) IsHidden() bool

type CounterMetric

type CounterMetric interface {
	Inc()
	Add(float64)
}

CounterMetric is an interface which defines a subset of the interface provided by prometheus.Counter

type CounterOpts

type CounterOpts KubeOpts

CounterOpts is an alias for Opts. See there for doc comments.

type CounterVec

type CounterVec struct {
	*prometheus.CounterVec
	*CounterOpts
	// contains filtered or unexported fields
}

CounterVec is the internal representation of our wrapping struct around prometheus counterVecs. CounterVec implements both kubeCollector and CounterVecMetric.

func NewCounterVec

func NewCounterVec(opts *CounterOpts, labels []string) *CounterVec

NewCounterVec returns an object which satisfies the kubeCollector and CounterVecMetric interfaces. However, the object returned will not measure anything unless the collector is first registered, since the metric is lazily instantiated.

func (*CounterVec) Create

func (r *CounterVec) Create(version *semver.Version) bool

Create forces the initialization of metric which has been deferred until the point at which this method is invoked. This method will determine whether the metric is deprecated or hidden, no-opting if the metric should be considered hidden. Furthermore, this function no-opts and returns true if metric is already created.

func (*CounterVec) Delete

func (v *CounterVec) Delete(labels prometheus.Labels) bool

Delete deletes the metric where the variable labels are the same as those passed in as labels. It returns true if a metric was deleted.

It is not an error if the number and names of the Labels are inconsistent with those of the VariableLabels in Desc. However, such inconsistent Labels can never match an actual metric, so the method will always return false in that case.

func (*CounterVec) DeprecatedVersion

func (v *CounterVec) DeprecatedVersion() *semver.Version

DeprecatedVersion returns a pointer to the Version or nil

func (*CounterVec) IsCreated

func (r *CounterVec) IsCreated() bool

func (*CounterVec) IsDeprecated

func (r *CounterVec) IsDeprecated() bool

func (*CounterVec) IsHidden

func (r *CounterVec) IsHidden() bool

func (*CounterVec) With

func (v *CounterVec) With(labels prometheus.Labels) CounterMetric

With returns the Counter for the given Labels map (the label names must match those of the VariableLabels in Desc). If that label map is accessed for the first time, a new Counter is created IFF the counterVec has been registered to a metrics registry.

func (*CounterVec) WithLabelValues

func (v *CounterVec) WithLabelValues(lvs ...string) CounterMetric

WithLabelValues returns the Counter for the given slice of label values (same order as the VariableLabels in Desc). If that combination of label values is accessed for the first time, a new Counter is created IFF the counterVec has been registered to a metrics registry.

type CounterVecMetric

type CounterVecMetric interface {
	WithLabelValues(...string) CounterMetric
	With(prometheus.Labels) CounterMetric
}

CounterVecMetric is an interface which prometheus.CounterVec satisfies.

type Gauge

type Gauge struct {
	GaugeMetric
	*GaugeOpts
	// contains filtered or unexported fields
}

Gauge is our internal representation for our wrapping struct around prometheus gauges. kubeGauge implements both kubeCollector and KubeGauge.

func NewGauge

func NewGauge(opts *GaugeOpts) *Gauge

NewGauge returns an object which satisfies the kubeCollector and KubeGauge interfaces. However, the object returned will not measure anything unless the collector is first registered, since the metric is lazily instantiated.

func (*Gauge) Collect

func (c *Gauge) Collect(ch chan<- prometheus.Metric)

func (*Gauge) Create

func (r *Gauge) Create(version *semver.Version) bool

Create forces the initialization of metric which has been deferred until the point at which this method is invoked. This method will determine whether the metric is deprecated or hidden, no-opting if the metric should be considered hidden. Furthermore, this function no-opts and returns true if metric is already created.

func (*Gauge) DeprecatedVersion

func (g *Gauge) DeprecatedVersion() *semver.Version

DeprecatedVersion returns a pointer to the Version or nil

func (*Gauge) Describe

func (c *Gauge) Describe(ch chan<- *prometheus.Desc)

func (*Gauge) IsCreated

func (r *Gauge) IsCreated() bool

func (*Gauge) IsDeprecated

func (r *Gauge) IsDeprecated() bool

func (*Gauge) IsHidden

func (r *Gauge) IsHidden() bool

type GaugeMetric

type GaugeMetric interface {
	Set(float64)
	Inc()
	Dec()
	Add(float64)
	Write(out *dto.Metric) error
	SetToCurrentTime()
}

GaugeMetric is an interface which defines a subset of the interface provided by prometheus.Gauge

type GaugeOpts

type GaugeOpts KubeOpts

GaugeOpts is an alias for Opts. See there for doc comments.

type GaugeVec

type GaugeVec struct {
	*prometheus.GaugeVec
	*GaugeOpts
	// contains filtered or unexported fields
}

GaugeVec is the internal representation of our wrapping struct around prometheus gaugeVecs. kubeGaugeVec implements both kubeCollector and KubeGaugeVec.

func NewGaugeVec

func NewGaugeVec(opts *GaugeOpts, labels []string) *GaugeVec

NewGaugeVec returns an object which satisfies the kubeCollector and KubeGaugeVec interfaces. However, the object returned will not measure anything unless the collector is first registered, since the metric is lazily instantiated.

func (*GaugeVec) Create

func (r *GaugeVec) Create(version *semver.Version) bool

Create forces the initialization of metric which has been deferred until the point at which this method is invoked. This method will determine whether the metric is deprecated or hidden, no-opting if the metric should be considered hidden. Furthermore, this function no-opts and returns true if metric is already created.

func (*GaugeVec) Delete

func (v *GaugeVec) Delete(labels prometheus.Labels) bool

Delete deletes the metric where the variable labels are the same as those passed in as labels. It returns true if a metric was deleted.

It is not an error if the number and names of the Labels are inconsistent with those of the VariableLabels in Desc. However, such inconsistent Labels can never match an actual metric, so the method will always return false in that case.

func (*GaugeVec) DeprecatedVersion

func (v *GaugeVec) DeprecatedVersion() *semver.Version

DeprecatedVersion returns a pointer to the Version or nil

func (*GaugeVec) IsCreated

func (r *GaugeVec) IsCreated() bool

func (*GaugeVec) IsDeprecated

func (r *GaugeVec) IsDeprecated() bool

func (*GaugeVec) IsHidden

func (r *GaugeVec) IsHidden() bool

func (*GaugeVec) With

func (v *GaugeVec) With(labels prometheus.Labels) GaugeMetric

With returns the GaugeMetric for the given Labels map (the label names must match those of the VariableLabels in Desc). If that label map is accessed for the first time, a new GaugeMetric is created IFF the gaugeVec has been registered to a metrics registry.

func (*GaugeVec) WithLabelValues

func (v *GaugeVec) WithLabelValues(lvs ...string) GaugeMetric

WithLabelValues returns the GaugeMetric for the given slice of label values (same order as the VariableLabels in Desc). If that combination of label values is accessed for the first time, a new GaugeMetric is created IFF the gaugeVec has been registered to a metrics registry.

type Histogram

type Histogram struct {
	ObserverMetric
	*HistogramOpts
	// contains filtered or unexported fields
}

Histogram is our internal representation for our wrapping struct around prometheus histograms. Summary implements both kubeCollector and ObserverMetric

func NewHistogram

func NewHistogram(opts *HistogramOpts) *Histogram

NewHistogram returns an object which is Histogram-like. However, nothing will be measured until the histogram is registered somewhere.

func (*Histogram) Collect

func (c *Histogram) Collect(ch chan<- prometheus.Metric)

func (*Histogram) Create

func (r *Histogram) Create(version *semver.Version) bool

Create forces the initialization of metric which has been deferred until the point at which this method is invoked. This method will determine whether the metric is deprecated or hidden, no-opting if the metric should be considered hidden. Furthermore, this function no-opts and returns true if metric is already created.

func (*Histogram) DeprecatedVersion

func (h *Histogram) DeprecatedVersion() *semver.Version

DeprecatedVersion returns a pointer to the Version or nil

func (*Histogram) Describe

func (c *Histogram) Describe(ch chan<- *prometheus.Desc)

func (*Histogram) IsCreated

func (r *Histogram) IsCreated() bool

func (*Histogram) IsDeprecated

func (r *Histogram) IsDeprecated() bool

func (*Histogram) IsHidden

func (r *Histogram) IsHidden() bool

type HistogramOpts

type HistogramOpts struct {
	Namespace         string
	Subsystem         string
	Name              string
	Help              string
	ConstLabels       prometheus.Labels
	Buckets           []float64
	DeprecatedVersion string

	StabilityLevel StabilityLevel
	// contains filtered or unexported fields
}

HistogramOpts bundles the options for creating a Histogram metric. It is mandatory to set Name to a non-empty string. All other fields are optional and can safely be left at their zero value, although it is strongly encouraged to set a Help string.

type HistogramVec

type HistogramVec struct {
	*prometheus.HistogramVec
	*HistogramOpts
	// contains filtered or unexported fields
}

HistogramVec is the internal representation of our wrapping struct around prometheus histogramVecs.

func NewHistogramVec

func NewHistogramVec(opts *HistogramOpts, labels []string) *HistogramVec

NewHistogramVec returns an object which satisfies kubeCollector and wraps the prometheus.HistogramVec object. However, the object returned will not measure anything unless the collector is first registered, since the metric is lazily instantiated.

func (*HistogramVec) Create

func (r *HistogramVec) Create(version *semver.Version) bool

Create forces the initialization of metric which has been deferred until the point at which this method is invoked. This method will determine whether the metric is deprecated or hidden, no-opting if the metric should be considered hidden. Furthermore, this function no-opts and returns true if metric is already created.

func (*HistogramVec) Delete

func (v *HistogramVec) Delete(labels prometheus.Labels) bool

Delete deletes the metric where the variable labels are the same as those passed in as labels. It returns true if a metric was deleted.

It is not an error if the number and names of the Labels are inconsistent with those of the VariableLabels in Desc. However, such inconsistent Labels can never match an actual metric, so the method will always return false in that case.

func (*HistogramVec) DeprecatedVersion

func (v *HistogramVec) DeprecatedVersion() *semver.Version

DeprecatedVersion returns a pointer to the Version or nil

func (*HistogramVec) IsCreated

func (r *HistogramVec) IsCreated() bool

func (*HistogramVec) IsDeprecated

func (r *HistogramVec) IsDeprecated() bool

func (*HistogramVec) IsHidden

func (r *HistogramVec) IsHidden() bool

func (*HistogramVec) With

func (v *HistogramVec) With(labels prometheus.Labels) ObserverMetric

With returns the ObserverMetric for the given Labels map (the label names must match those of the VariableLabels in Desc). If that label map is accessed for the first time, a new ObserverMetric is created IFF the HistogramVec has been registered to a metrics registry.

func (*HistogramVec) WithLabelValues

func (v *HistogramVec) WithLabelValues(lvs ...string) ObserverMetric

WithLabelValues returns the ObserverMetric for the given slice of label values (same order as the VariableLabels in Desc). If that combination of label values is accessed for the first time, a new ObserverMetric is created IFF the HistogramVec has been registered to a metrics registry.

type KubeOpts

type KubeOpts struct {
	Namespace         string
	Subsystem         string
	Name              string
	Help              string
	ConstLabels       prometheus.Labels
	DeprecatedVersion string

	StabilityLevel StabilityLevel
	// contains filtered or unexported fields
}

KubeOpts is superset struct for prometheus.Opts. The prometheus Opts structure is purposefully not embedded here because that would change struct initialization in the manner which people are currently accustomed.

Name must be set to a non-empty string. DeprecatedVersion is defined only if the metric for which this options applies is, in fact, deprecated.

type KubeRegistry

type KubeRegistry interface {
	// Deprecated
	RawRegister(prometheus.Collector) error
	// Deprecated
	RawMustRegister(...prometheus.Collector)
	Register(Registerable) error
	MustRegister(...Registerable)
	Unregister(Registerable) bool
	Gather() ([]*dto.MetricFamily, error)
}

KubeRegistry is an interface which implements a subset of prometheus.Registerer and prometheus.Gatherer interfaces

func NewKubeRegistry

func NewKubeRegistry() KubeRegistry

NewKubeRegistry creates a new vanilla Registry without any Collectors pre-registered.

type Metric

type Metric interface {
	Desc() *prometheus.Desc
	Write(*dto.Metric) error
}

Metric defines a subset of prometheus.Metric interface methods

type ObserverMetric

type ObserverMetric interface {
	Observe(float64)
}

ObserverMetric captures individual observations.

type PromRegistry

type PromRegistry interface {
	Register(prometheus.Collector) error
	MustRegister(...prometheus.Collector)
	Unregister(prometheus.Collector) bool
	Gather() ([]*dto.MetricFamily, error)
}

PromRegistry is an interface which implements a subset of prometheus.Registerer and prometheus.Gatherer interfaces

type Registerable

type Registerable interface {
	prometheus.Collector
	Create(version *semver.Version) bool
}

Registerable is an interface for a collector metric which we will register with KubeRegistry.

type Registerer

type Registerer interface {
	Register(prometheus.Collector) error
}

Registerer is an interface expected by RegisterProcessStartTime in order to register the metric

type StabilityLevel

type StabilityLevel string

StabilityLevel represents the API guarantees for a given defined metric.

const (
	// ALPHA metrics have no stability guarantees, as such, labels may
	// be arbitrarily added/removed and the metric may be deleted at any time.
	ALPHA StabilityLevel = "ALPHA"
	// STABLE metrics are guaranteed not be mutated and removal is governed by
	// the deprecation policy outlined in by the control plane metrics stability KEP.
	STABLE StabilityLevel = "STABLE"
)

type Summary

type Summary struct {
	ObserverMetric
	*SummaryOpts
	// contains filtered or unexported fields
}

Summary is our internal representation for our wrapping struct around prometheus summaries. Summary implements both kubeCollector and ObserverMetric

DEPRECATED: as per the metrics overhaul KEP

func NewSummary

func NewSummary(opts *SummaryOpts) *Summary

NewSummary returns an object which is Summary-like. However, nothing will be measured until the summary is registered somewhere.

DEPRECATED: as per the metrics overhaul KEP

func (*Summary) Collect

func (c *Summary) Collect(ch chan<- prometheus.Metric)

func (*Summary) Create

func (r *Summary) Create(version *semver.Version) bool

Create forces the initialization of metric which has been deferred until the point at which this method is invoked. This method will determine whether the metric is deprecated or hidden, no-opting if the metric should be considered hidden. Furthermore, this function no-opts and returns true if metric is already created.

func (*Summary) DeprecatedVersion

func (s *Summary) DeprecatedVersion() *semver.Version

DeprecatedVersion returns a pointer to the Version or nil

func (*Summary) Describe

func (c *Summary) Describe(ch chan<- *prometheus.Desc)

func (*Summary) IsCreated

func (r *Summary) IsCreated() bool

func (*Summary) IsDeprecated

func (r *Summary) IsDeprecated() bool

func (*Summary) IsHidden

func (r *Summary) IsHidden() bool

type SummaryOpts

type SummaryOpts struct {
	Namespace         string
	Subsystem         string
	Name              string
	Help              string
	ConstLabels       prometheus.Labels
	Objectives        map[float64]float64
	MaxAge            time.Duration
	AgeBuckets        uint32
	BufCap            uint32
	DeprecatedVersion string

	StabilityLevel StabilityLevel
	// contains filtered or unexported fields
}

SummaryOpts bundles the options for creating a Summary metric. It is mandatory to set Name to a non-empty string. While all other fields are optional and can safely be left at their zero value, it is recommended to set a help string and to explicitly set the Objectives field to the desired value as the default value will change in the upcoming v0.10 of the library.

type SummaryVec

type SummaryVec struct {
	*prometheus.SummaryVec
	*SummaryOpts
	// contains filtered or unexported fields
}

SummaryVec is the internal representation of our wrapping struct around prometheus summaryVecs.

DEPRECATED: as per the metrics overhaul KEP

func NewSummaryVec

func NewSummaryVec(opts *SummaryOpts, labels []string) *SummaryVec

NewSummaryVec returns an object which satisfies kubeCollector and wraps the prometheus.SummaryVec object. However, the object returned will not measure anything unless the collector is first registered, since the metric is lazily instantiated.

DEPRECATED: as per the metrics overhaul KEP

func (*SummaryVec) Create

func (r *SummaryVec) Create(version *semver.Version) bool

Create forces the initialization of metric which has been deferred until the point at which this method is invoked. This method will determine whether the metric is deprecated or hidden, no-opting if the metric should be considered hidden. Furthermore, this function no-opts and returns true if metric is already created.

func (*SummaryVec) Delete

func (v *SummaryVec) Delete(labels prometheus.Labels) bool

Delete deletes the metric where the variable labels are the same as those passed in as labels. It returns true if a metric was deleted.

It is not an error if the number and names of the Labels are inconsistent with those of the VariableLabels in Desc. However, such inconsistent Labels can never match an actual metric, so the method will always return false in that case.

func (*SummaryVec) DeprecatedVersion

func (v *SummaryVec) DeprecatedVersion() *semver.Version

DeprecatedVersion returns a pointer to the Version or nil

func (*SummaryVec) IsCreated

func (r *SummaryVec) IsCreated() bool

func (*SummaryVec) IsDeprecated

func (r *SummaryVec) IsDeprecated() bool

func (*SummaryVec) IsHidden

func (r *SummaryVec) IsHidden() bool

func (*SummaryVec) With

func (v *SummaryVec) With(labels prometheus.Labels) ObserverMetric

With returns the ObserverMetric for the given Labels map (the label names must match those of the VariableLabels in Desc). If that label map is accessed for the first time, a new ObserverMetric is created IFF the summaryVec has been registered to a metrics registry.

func (*SummaryVec) WithLabelValues

func (v *SummaryVec) WithLabelValues(lvs ...string) ObserverMetric

WithLabelValues returns the ObserverMetric for the given slice of label values (same order as the VariableLabels in Desc). If that combination of label values is accessed for the first time, a new ObserverMetric is created IFF the summaryVec has been registered to a metrics registry.

Directories

Path Synopsis
prometheus

Jump to

Keyboard shortcuts

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