label

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2023 License: Unlicense Imports: 8 Imported by: 0

Documentation

Overview

This package deals with sets of metric labels and lists of label values.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type RuneList

type RuneList string

A RuneList is just a string. It is used to store a list of values of type `rune`.

func (RuneList) String

func (rl RuneList) String() string

Converts a RuneList into a string containing the (decimal) rune values separated by "."s. Makes a RuneList easy to read instead of a string full of control characters. Useful if a RuneList ends up in a log message.

type Set

type Set struct {
	SkippedKeys []string // Sorted list of omitted label names.
	// contains filtered or unexported fields
}

A label.Set tracks the possible label names and seen label values for a metric.

func (*Set) Init

func (ls *Set) Init(
	skipKeys []string,
	labelDescs []*monitoring.LabelDescriptor,
	resourceLabels map[string]bool,
)

Initializes a new label.Set to track the passed-in metric labels and resource labels, ignoring any labels in `skipKeys`.

func (*Set) KeptKeys

func (ls *Set) KeptKeys() []string

Returns the list of kept label names.

func (*Set) LabelPairs

func (ls *Set) LabelPairs(rl RuneList) []*dto.LabelPair

Converts a RuneList into a list of LabelPairs ready to export.

func (*Set) Len

func (ls *Set) Len() int

Returns the number of kept label names.

func (*Set) RuneList

func (ls *Set) RuneList(
	metricLabels map[string]string,
	resourceLabels map[string]string,
) RuneList

Converts the label values from a TimeSeries into a RuneList.

func (*Set) ValueList

func (ls *Set) ValueList(rl RuneList) []string

Converts a RuneList into a list of just the label value strings.

type Values

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

A label.Values contains all of the seen label values (regardless of label name) and provides a mapping between each unique value and a rune. This allows a list of label values to be recorded very compactly (in a short string) which also provides an efficient way to find the prior metric having identical label values (via a map[string] type).

func (*Values) Len

func (vs *Values) Len() int

Returns 1 plus the count of already-seen unique label values.

func (*Values) Rune

func (vs *Values) Rune(val string) rune

Converts a label value into a rune.

func (*Values) Value

func (vs *Values) Value(pos rune) string

Converts a rune into a label value. Will panic() if the rune value is out-of-range.

Jump to

Keyboard shortcuts

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