metrics

package
v0.7.0-nightly.20230617 Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2023 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Register

func Register(r Registry)

Register adds a Registry to the global registries. Any metrics that were created prior or after this call will also be created in this registry. This function is not thread safe, registries should be registered either before or after creating metrics, but not at the same time.

Types

type Counter

type Counter interface {
	// Inc adds Sum(vs) to the counter. Sum(vs) must be positive.
	//
	// If len(vs) == 0, increments the counter by 1.
	Inc(vs ...float64)
}

Counter is a metric that can only increment its current count.

func NewCounter

func NewCounter(name, help string, opts ...Option) Counter

type Gauge

type Gauge interface {
	// Inc adds Sum(vs) to the gauge. Sum(vs) must be positive.
	//
	// If len(vs) == 0, increments the gauge by 1.
	Inc(vs ...float64)
	// Dec subtracts Sum(vs) from the gauge. Sum(vs) must be positive.
	//
	// If len(vs) == 0, decrements the gauge by 1.
	Dec(vs ...float64)

	// Set replaces the gauge's current value with the provided value
	Set(float64)
}

Gauge is a metric that allows incrementing and decrementing a value.

func NewGauge

func NewGauge(name, help string, opts ...Option) Gauge

type Histogram

type Histogram interface {
	Observe(float64)
}

Histogram is a metric that builds a histogram from observed values.

func NewHistogram

func NewHistogram(name, help string, opts ...Option) Histogram

type LabeledCounter

type LabeledCounter interface {
	WithValues(vs ...string) Counter
}

LabeledCounter is a counter that must have labels populated before use.

func NewLabeledCounter

func NewLabeledCounter(name, help string, labels []string, opts ...Option) LabeledCounter

type LabeledGauge

type LabeledGauge interface {
	WithValues(labels ...string) Gauge
}

LabeledGauge describes a gauge that must have values populated before use.

func NewLabeledGauge

func NewLabeledGauge(name, help string, labels []string, opts ...Option) LabeledGauge

type LabeledHistogram

type LabeledHistogram interface {
	WithValues(labels ...string) Histogram
}

LabeledHistogram describes a histogram that must have labels populated before use.

func NewLabeledHistogram

func NewLabeledHistogram(name, help string, labels []string, opts ...Option) LabeledHistogram

type LabeledTimer

type LabeledTimer interface {
	WithValues(labels ...string) Timer
}

LabeledTimer is a timer that must have label values populated before use.

func NewLabeledTimer

func NewLabeledTimer(name, help string, labels []string, opts ...Option) LabeledTimer

type Option

type Option interface{}

Option is an option that can be applied on a metric. Registry implementations can and should define their own unique Option interface and only apply options meant for them.

type RecordBytesHistogram added in v0.5.0

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

RecordBytesHistogram wraps a histrogram metric and allows to observe record sizes in bytes.

func NewRecordBytesHistogram added in v0.5.0

func NewRecordBytesHistogram(h Histogram) RecordBytesHistogram

func (RecordBytesHistogram) Observe added in v0.5.0

func (m RecordBytesHistogram) Observe(r record.Record)

type Registry

type Registry interface {
	NewCounter(name, help string, opts ...Option) Counter
	NewGauge(name, help string, opts ...Option) Gauge
	NewTimer(name, help string, opts ...Option) Timer
	NewHistogram(name, help string, opts ...Option) Histogram

	NewLabeledCounter(name, help string, labels []string, opts ...Option) LabeledCounter
	NewLabeledGauge(name, help string, labels []string, opts ...Option) LabeledGauge
	NewLabeledTimer(name, help string, labels []string, opts ...Option) LabeledTimer
	NewLabeledHistogram(name, help string, labels []string, opts ...Option) LabeledHistogram
}

Registry is an object that can create and collect metrics.

type Timer

type Timer interface {
	// Update records a duration.
	Update(time.Duration)

	// UpdateSince will add the duration from the provided starting time to the
	// timer's summary.
	UpdateSince(time.Time)
}

Timer is a metric that allows collecting the duration of an action in seconds.

func NewTimer

func NewTimer(name, help string, opts ...Option) Timer

Directories

Path Synopsis
Package noop exposes implementations of metrics which do not do anything.
Package noop exposes implementations of metrics which do not do anything.

Jump to

Keyboard shortcuts

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