metric

package
v1.9.8 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2021 License: Apache-2.0 Imports: 6 Imported by: 14

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ComposeMetricGenFuncs

func ComposeMetricGenFuncs(familyGens []FamilyGenerator) func(obj interface{}) []metricsstore.FamilyByteSlicer

ComposeMetricGenFuncs takes a slice of metric families and returns a function that composes their metric generation functions into a single one.

func ExtractMetricFamilyHeaders

func ExtractMetricFamilyHeaders(families []FamilyGenerator) []string

ExtractMetricFamilyHeaders takes in a slice of FamilyGenerator metrics and returns the extracted headers.

Types

type Family

type Family struct {
	Name    string
	Metrics []*Metric
}

Family represents a set of metrics with the same name and help text.

func (Family) ByteSlice

func (f Family) ByteSlice() []byte

ByteSlice returns the given Family in its string representation.

type FamilyGenerator

type FamilyGenerator struct {
	Name         string
	Help         string
	Type         Type
	GenerateFunc func(obj interface{}) *Family
}

FamilyGenerator provides everything needed to generate a metric family with a Kubernetes object.

func FilterMetricFamilies

func FilterMetricFamilies(l whiteBlackLister, families []FamilyGenerator) []FamilyGenerator

FilterMetricFamilies takes a white- and a blacklist and a slice of metric families and returns a filtered slice.

func (*FamilyGenerator) Generate

func (g *FamilyGenerator) Generate(obj interface{}) *Family

Generate calls the FamilyGenerator.GenerateFunc and gives the family its name. The reasoning behind injecting the name at such a late point in time is deduplication in the code, preventing typos made by developers as well as saving memory.

type Metric

type Metric struct {
	// The name of a metric is injected by its family to reduce duplication.
	LabelKeys   []string
	LabelValues []string
	Value       float64
}

Metric represents a single time series.

func (*Metric) Write

func (m *Metric) Write(s *strings.Builder)

type Type

type Type string

Type represents the type of a metric e.g. a counter. See https://prometheus.io/docs/concepts/metric_types/.

var Counter Type = "counter"

Counter defines a Prometheus counter.

var Gauge Type = "gauge"

Gauge defines a Prometheus gauge.

Jump to

Keyboard shortcuts

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