metric

package
v16.15.0 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewMetrics

func NewMetrics() *metrics

NewMetrics returns a new metrics instance.

Types

type Collector

type Collector interface {
	Prefix() string
	Describe() []*Description
	Collect() Metrics
	Stop()
}

type Description

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

func NewDesc

func NewDesc(name, description string, labels []string) *Description

func (*Description) Description

func (d *Description) Description() string

func (*Description) Labels added in v16.10.0

func (d *Description) Labels() []string

func (*Description) Name

func (d *Description) Name() string

func (*Description) String added in v16.10.0

func (d *Description) String() string

type Metrics

type Metrics interface {
	// Value returns the first value that matches the name and the labels. The labels
	// are used to create a pattern and therefore must obey to the rules of NewPattern.
	Value(name string, labels ...string) Value

	// Values returns all values that matches the name and the labels. The labels
	// are used to create a pattern and therefore must obey to the rules of NewPattern.
	Values(name string, labels ...string) []Value

	// Labels return a list of all values for a label.
	Labels(name string, label string) []string

	// All returns all values currently stored in the collection.
	All() []Value

	// Add adds a value to the collection.
	Add(v Value)

	// String return a string representation of all collected values.
	String() string
}

Metrics is a collection of values

type Pattern

type Pattern interface {
	// Name returns the name of the metric this pattern is designated to.
	Name() string

	// Match returns whether a map of labels with its label values
	// match this pattern. All labels have to be present and need to match.
	Match(labels map[string]string) bool

	// IsValid returns whether the pattern is valid.
	IsValid() bool
}

func NewPattern

func NewPattern(name string, labels ...string) Pattern

NewPattern creates a new pattern with the given prefix and group name. There has to be an even number of labels, which is ("label", "labelvalue", "label", "labelvalue" ...). The label value will be interpreted as regular expression.

type Reader

type Reader interface {
	Collect([]Pattern) Metrics
}

type Value

type Value interface {
	Name() string
	Val() float64
	L(name string) string
	Labels() map[string]string
	Match(patterns []Pattern) bool
	Hash() string
	String() string
}

func NewValue

func NewValue(description *Description, v float64, elms ...string) Value

Jump to

Keyboard shortcuts

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