Skip to content

Import path: gitlab.soludian.com/soludian/fountain/libs/metrics

metrics

go
import "gitlab.soludian.com/soludian/fountain/libs/metrics"

Index

type Counter

Counter describes a metric that accumulates values monotonically. An example of a counter is the number of received HTTP requests.

go
type Counter interface {
    With(labelValues ...string) Counter
    Add(delta float64)
}

type Gauge

Gauge describes a metric that takes specific values over time. An example of a gauge is the current depth of a job queue.

go
type Gauge interface {
    With(labelValues ...string) Gauge
    Set(value float64)
    Add(delta float64)
}

type Histogram

Histogram describes a metric that takes repeated observations of the same kind of thing, and produces a statistical summary of those observations, typically expressed as quantiles or buckets. An example of a histogram is HTTP request latencies.

go
type Histogram interface {
    With(labelValues ...string) Histogram
    Observe(value float64)
}

type Timer

Timer acts as a stopwatch, sending observations to a wrapped histogram. It's a bit of helpful syntax sugar for h.Observe(time.Since(x)).

go
type Timer struct {
    // contains filtered or unexported fields
}

func NewTimer

go
func NewTimer(h Histogram) *Timer

NewTimer wraps the given histogram and records the current time.

func (*Timer) ObserveDuration

go
func (t *Timer) ObserveDuration()

ObserveDuration captures the number of seconds since the timer was constructed, and forwards that observation to the histogram.

func (*Timer) Unit

go
func (t *Timer) Unit(u time.Duration)

Unit sets the unit of the float64 emitted by the timer. By default, the timer emits seconds.

Generated by gomarkdoc