metric

package
v0.0.0-...-4125756 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Metrics

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

Metrics defines a set of metric collection.

func New

func New() *Metrics

New create a new metrics.

func (*Metrics) Increment

func (m *Metrics) Increment(name string, val float64, labels ...string) error

Increment adds the given value to a counter or gauge metric. The name and labels must match a previously defined metric. Gauge metrics support subtraction by use of a negative value. Counter metrics only allow addition and a negative value will result in an error.

func (*Metrics) Observe

func (m *Metrics) Observe(name string, val float64, labels ...string) error

Observe observes the given value using a histogram or summary, or sets it as a gauge's value. The name and labels must match a previously defined metric.

func (*Metrics) Register

func (m *Metrics) Register(name, help string, opts ...Option) error

Register register a new metric.

func (*Metrics) Set

func (m *Metrics) Set(name string, val float64, labels ...string) error

Set replace the given value to a gauge metric. The name and labels must match a previously defined metric.

type Option

type Option func(c *metric) error

An Option is used to construct a metric.

func Counter

func Counter() Option

Counter represents a single numerical value that only ever goes up.

func Gauge

func Gauge() Option

Gauge represents a single numerical value that can arbitrarily go up and down.

func Histogram

func Histogram(buckets ...float64) Option

Histogram counts individual observations from an event or sample stream in configurable buckets.

Warning: Histograms are expensive and should be used sparingly.

func Labels

func Labels(labels ...string) Option

Labels describes the label names of this metric.

func MaxAge

func MaxAge(maxAge time.Duration) Option

MaxAge defines the duration for which an observation stays relevant for summary metrics. Must be positive.

func Summary

func Summary(objectives map[float64]float64) Option

Summary captures individual observations from an event or sample stream and summarizes them in a manner similar to traditional summary statistics: 1. sum of observations 2. observation count 3. rank estimations.

Warning: Summaries with objectives are expensive and should be used sparingly.

Jump to

Keyboard shortcuts

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