operatormetrics

package
v0.0.0-...-09a8804 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2023 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterCollector

func RegisterCollector(collectors ...Collector) error

RegisterCollector registers the collector with the Prometheus registry.

func RegisterMetrics

func RegisterMetrics(allMetrics ...[]Metric) error

RegisterMetrics registers the metrics with the Prometheus registry.

Types

type Collector

type Collector struct {
	// Metrics is a list of metrics to be collected by the collector.
	Metrics []Metric

	// CollectCallback is a function that returns a list of CollectionResults.
	// The CollectionResults are used to populate the metrics in the collector.
	CollectCallback func() []CollectorResult
}

Collector registers a prometheus.Collector with a set of metrics in the Prometheus registry. The metrics are collected by calling the CollectCallback function.

func (Collector) Collect

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

func (Collector) Describe

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

type CollectorResult

type CollectorResult struct {
	Metric Metric
	Labels []string
	Value  float64
}

type Counter

type Counter struct {
	prometheus.Counter
	// contains filtered or unexported fields
}

func NewCounter

func NewCounter(metricOpts MetricOpts) *Counter

NewCounter creates a new Counter. The Counter must be registered with the Prometheus registry through RegisterMetrics.

func (*Counter) GetOpts

func (c *Counter) GetOpts() MetricOpts

func (*Counter) GetType

func (c *Counter) GetType() MetricType

type CounterVec

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

func NewCounterVec

func NewCounterVec(metricOpts MetricOpts, labels []string) *CounterVec

NewCounterVec creates a new CounterVec. The CounterVec must be registered with the Prometheus registry through RegisterMetrics.

func (*CounterVec) GetOpts

func (c *CounterVec) GetOpts() MetricOpts

func (*CounterVec) GetType

func (c *CounterVec) GetType() MetricType

type Gauge

type Gauge struct {
	prometheus.Gauge
	// contains filtered or unexported fields
}

func NewGauge

func NewGauge(metricOpts MetricOpts) *Gauge

NewGauge creates a new Gauge. The Gauge must be registered with the Prometheus registry through RegisterMetrics.

func (*Gauge) GetOpts

func (c *Gauge) GetOpts() MetricOpts

func (*Gauge) GetType

func (c *Gauge) GetType() MetricType

type GaugeVec

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

func NewGaugeVec

func NewGaugeVec(metricOpts MetricOpts, labels []string) *GaugeVec

NewGaugeVec creates a new GaugeVec. The GaugeVec must be registered with the Prometheus registry through RegisterMetrics.

func (*GaugeVec) GetOpts

func (c *GaugeVec) GetOpts() MetricOpts

func (*GaugeVec) GetType

func (c *GaugeVec) GetType() MetricType

type Histogram

type Histogram struct {
	prometheus.Histogram
	// contains filtered or unexported fields
}

func NewHistogram

func NewHistogram(metricOpts MetricOpts, histogramOpts HistogramOpts) *Histogram

NewHistogram creates a new Histogram. The Histogram must be registered with the Prometheus registry through RegisterMetrics.

func (*Histogram) GetHistogramOpts

func (c *Histogram) GetHistogramOpts() HistogramOpts

func (*Histogram) GetOpts

func (c *Histogram) GetOpts() MetricOpts

func (*Histogram) GetType

func (c *Histogram) GetType() MetricType

type HistogramOpts

type HistogramOpts struct {
	Buckets                         []float64
	NativeHistogramBucketFactor     float64
	NativeHistogramZeroThreshold    float64
	NativeHistogramMaxBucketNumber  uint32
	NativeHistogramMinResetDuration time.Duration
	NativeHistogramMaxZeroThreshold float64
}

type HistogramVec

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

func NewHistogramVec

func NewHistogramVec(metricOpts MetricOpts, histogramOpts HistogramOpts, labels []string) *HistogramVec

NewHistogramVec creates a new HistogramVec. The HistogramVec must be registered with the Prometheus registry through RegisterMetrics.

func (*HistogramVec) GetHistogramOpts

func (c *HistogramVec) GetHistogramOpts() HistogramOpts

func (*HistogramVec) GetOpts

func (c *HistogramVec) GetOpts() MetricOpts

func (*HistogramVec) GetType

func (c *HistogramVec) GetType() MetricType

type Metric

type Metric interface {
	GetOpts() MetricOpts
	GetType() MetricType
	// contains filtered or unexported methods
}

func ListMetrics

func ListMetrics() []Metric

ListMetrics returns a list of all registered metrics.

type MetricOpts

type MetricOpts struct {
	Name string
	Help string

	ConstLabels map[string]string

	ExtraFields map[string]string
}

type MetricType

type MetricType string
const (
	CounterType   MetricType = "Counter"
	GaugeType     MetricType = "Gauge"
	HistogramType MetricType = "Histogram"
	SummaryType   MetricType = "Summary"

	CounterVecType   MetricType = "CounterVec"
	GaugeVecType     MetricType = "GaugeVec"
	HistogramVecType MetricType = "HistogramVec"
	SummaryVecType   MetricType = "SummaryVec"
)

type RegistryFunc

type RegistryFunc func(c prometheus.Collector) error

Register is the function used to register metrics and collectors by this package.

type Summary

type Summary struct {
	prometheus.Summary
	// contains filtered or unexported fields
}

func NewSummary

func NewSummary(metricOpts MetricOpts, summaryOpts SummaryOpts) *Summary

NewSummary creates a new Summary. The Summary must be registered with the Prometheus registry through RegisterMetrics.

func (*Summary) GetOpts

func (c *Summary) GetOpts() MetricOpts

func (*Summary) GetSummaryOpts

func (c *Summary) GetSummaryOpts() SummaryOpts

func (*Summary) GetType

func (c *Summary) GetType() MetricType

type SummaryOpts

type SummaryOpts struct {
	Objectives map[float64]float64
	MaxAge     time.Duration
	AgeBuckets uint32
	BufCap     uint32
}

type SummaryVec

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

func NewSummaryVec

func NewSummaryVec(metricOpts MetricOpts, summaryOpts SummaryOpts, labels []string) *SummaryVec

NewSummaryVec creates a new SummaryVec. The SummaryVec must be registered with the Prometheus registry through RegisterMetrics.

func (*SummaryVec) GetOpts

func (c *SummaryVec) GetOpts() MetricOpts

func (*SummaryVec) GetSummaryOpts

func (c *SummaryVec) GetSummaryOpts() SummaryOpts

func (*SummaryVec) GetType

func (c *SummaryVec) GetType() MetricType

Jump to

Keyboard shortcuts

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