metric

package
v0.0.0-...-c3423aa Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2023 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package metric is the package to report the metrics to Prometheus

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddConstLabels

func AddConstLabels(labels prometheus.Labels, constLabels prometheus.Labels) prometheus.Labels

AddConstLabels append user defined labels in the configuration file to the predefined label set.

func Counter

func Counter(key string) *prometheus.CounterVec

Counter get the counter metric by key

func Gauge

func Gauge(key string) *prometheus.GaugeVec

Gauge get the gauge metric by key

func GetName

func GetName(fields ...string) string

GetName generate the metric key by a number of strings

func NewCounter

func NewCounter(namespace, subsystem, name, metric string,
	help string, labels []string, constLabels prometheus.Labels) *prometheus.CounterVec

NewCounter create the counter metric

func NewGauge

func NewGauge(namespace, subsystem, name, metric string,
	help string, labels []string, constLabels prometheus.Labels) *prometheus.GaugeVec

NewGauge create the gauge metric

func RemoveInvalidChars

func RemoveInvalidChars(name string) string

RemoveInvalidChars remove invalid chars

func ValidLabelName

func ValidLabelName(label string) bool

ValidLabelName check if the label name is valid

func ValidMetricChar

func ValidMetricChar(ch byte) bool

ValidMetricChar check if the char is valid for metric name

func ValidMetricName

func ValidMetricName(name string) bool

ValidMetricName check if the metric name is valid

Types

type MetricsType

MetricsType is the generic type of metrics

type PrometheusPushSink

type PrometheusPushSink struct {
	// contains filtered or unexported fields
}

func NewPrometheusPushSink

func NewPrometheusPushSink(namespace, address string, pushInterval time.Duration, done chan bool) *PrometheusPushSink

func (*PrometheusPushSink) Collect

func (p *PrometheusPushSink) Collect(c chan<- prometheus.Metric)

Collect meets the collection interface and allows us to enforce our expiration logic to clean up ephemeral metrics if their value haven't been set for a duration exceeding our allowed expiration time.

func (*PrometheusPushSink) Describe

func (p *PrometheusPushSink) Describe(c chan<- *prometheus.Desc)

Describe sends a Collector.Describe value from the descriptor created around PrometheusSink.Name Note that we cannot describe all the metrics (gauges, counters, summaries) in the sink as metrics can be added at any point during the lifecycle of the sink, which does not respect the idempotency aspect of the Collector.Describe() interface

Jump to

Keyboard shortcuts

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