metrics

package
v0.27.0 Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2021 License: GPL-3.0 Imports: 7 Imported by: 8

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefBuckets = []float64{.005, .01, .025, .05, .1, .25, .5, 1, 2.5, 5, 10}

DefBuckets are the default histogram buckets. The default buckets are tailored to broadly measure the response time (in seconds) of a network service. Most likely, however, you will be required to define buckets customized to your use case.

Functions

func ExponentialBuckets

func ExponentialBuckets(start, factor float64, count int) []float64

ExponentialBuckets creates 'count' buckets, where the lowest bucket has an upper bound of 'start' and each following bucket's upper bound is 'factor' times the previous bucket's upper bound. The final +Inf bucket is not counted and not included in the returned slice. The returned slice is meant to be used for the Buckets field of HistogramOpts.

The function panics if 'count' is 0 or negative, if 'start' is 0 or negative, or if 'factor' is less than or equal 1.

func LinearBuckets

func LinearBuckets(start, width float64, count int) []float64

LinearBuckets creates 'count' buckets, each 'width' wide, where the lowest bucket has an upper bound of 'start'. The final +Inf bucket is not counted and not included in the returned slice. The returned slice is meant to be used for the Buckets field of HistogramOpts.

The function panics if 'count' is zero or negative.

Types

type Counter

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

Counter is a Metric that represents a single numerical bits that only ever goes up. That implies that it cannot be used to count items whose number can also go down, e.g. the number of currently running goroutines. Those "counters" are represented by Gauges.

A Counter is typically used to count requests served, tasks completed, errors occurred, etc.

func (*Counter) Add

func (c *Counter) Add(v float64)

Add adds the given bits to the counter. It panics if the value is < 0.

func (*Counter) Inc

func (c *Counter) Inc()

Inc increments the counter by 1. Use Add to increment it by arbitrary non-negative values.

func (Counter) Value

func (c Counter) Value() float64

Value gets current counter.

func (Counter) WriteTo

func (c Counter) WriteTo(rv map[string]int64, key string, mul, div int)

WriteTo writes it's value into given map.

type CounterVec added in v0.11.0

type CounterVec map[string]*Counter

CounterVec is a Collector that bundles a set of Counters which have different values for their names. This is used if you want to count the same thing partitioned by various dimensions (e.g. number of HTTP requests, partitioned by response code and method).

Create instances with NewCounterVec.

func NewCounterVec added in v0.11.0

func NewCounterVec() CounterVec

NewCounterVec creates a new CounterVec

func (CounterVec) Get added in v0.11.0

func (c CounterVec) Get(name string) *Counter

Get gets counter instance by name

func (CounterVec) GetP added in v0.11.0

func (c CounterVec) GetP(name string) (counter *Counter, ok bool)

Get gets counter instance by name

func (CounterVec) WriteTo added in v0.11.0

func (c CounterVec) WriteTo(rv map[string]int64, key string, mul, div int)

WriteTo writes it's value into given map.

type Gauge

type Gauge float64

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

A Gauge is typically used for measured values like temperatures or current memory usage, but also "counts" that can go up and down, like the number of running goroutines.

func (*Gauge) Add

func (g *Gauge) Add(delta float64)

Add adds the given bits to the atomicGauge. (The bits can be negative, resulting in a decrease of the atomicGauge.)

func (*Gauge) Dec

func (g *Gauge) Dec()

Dec decrements the atomicGauge by 1. Use Sub to decrement it by arbitrary values.

func (*Gauge) Inc

func (g *Gauge) Inc()

Inc increments the atomicGauge by 1. Use Add to increment it by arbitrary values.

func (*Gauge) Set

func (g *Gauge) Set(v float64)

Set sets the atomicGauge to an arbitrary bits.

func (*Gauge) SetToCurrentTime

func (g *Gauge) SetToCurrentTime()

SetToCurrentTime sets the atomicGauge to the current Unix time in second.

func (*Gauge) Sub

func (g *Gauge) Sub(delta float64)

Sub subtracts the given bits from the atomicGauge. (The bits can be negative, resulting in an increase of the atomicGauge.)

func (Gauge) Value

func (g Gauge) Value() float64

Value gets current counter.

func (Gauge) WriteTo

func (g Gauge) WriteTo(rv map[string]int64, key string, mul, div int)

WriteTo writes it's value into given map.

type GaugeVec added in v0.11.0

type GaugeVec map[string]*Gauge

GaugeVec is a Collector that bundles a set of Gauges which have different values for their names. This is used if you want to count the same thing partitioned by various dimensions

Create instances with NewGaugeVec.

func NewGaugeVec added in v0.11.0

func NewGaugeVec() GaugeVec

NewGaugeVec creates a new GaugeVec

func (GaugeVec) Get added in v0.11.0

func (g GaugeVec) Get(name string) *Gauge

Get gets counter instance by name

func (GaugeVec) GetP added in v0.11.0

func (g GaugeVec) GetP(name string) (gauge *Gauge, ok bool)

Get gets counter instance by name

func (GaugeVec) WriteTo added in v0.11.0

func (g GaugeVec) WriteTo(rv map[string]int64, key string, mul, div int)

WriteTo writes it's value into given map.

type Histogram

type Histogram interface {
	Observer
}

A Histogram counts individual observations from an event or sample stream in configurable buckets. Similar to a summary, it also provides a sum of observations and an observation count.

Note that Histograms, in contrast to Summaries, can be aggregated. However, Histograms require the user to pre-define suitable buckets, and they are in general less accurate. The Observe method of a histogram has a very low performance overhead in comparison with the Observe method of a summary.

To create histogram instances, use NewHistogram.

func NewHistogram

func NewHistogram(buckets []float64) Histogram

NewHistogram creates a new Histogram.

type Observer

type Observer interface {
	stm.Value
	Observe(v float64)
}

Observer is a interface that wraps the Observe method, which is used by Histogram and Summary to add observations.

type Summary

type Summary interface {
	Observer
	Reset()
}

A Summary captures individual observations from an event or sample stream and summarizes them in a manner similar to traditional summary statistics:

sum of observations
observation count
observation average.

To create summary instances, use NewSummary.

func NewSummary

func NewSummary() Summary

NewSummary creates a new Summary.

type SummaryVec added in v0.11.0

type SummaryVec map[string]Summary

SummaryVec is a Collector that bundles a set of Summary which have different values for their names. This is used if you want to count the same thing partitioned by various dimensions (e.g. number of HTTP response time, partitioned by response code and method).

Create instances with NewSummaryVec.

func NewSummaryVec added in v0.11.0

func NewSummaryVec() SummaryVec

NewSummaryVec creates a new SummaryVec instance.

func (SummaryVec) Get added in v0.11.0

func (c SummaryVec) Get(name string) Summary

Get gets counter instance by name.

func (SummaryVec) Reset added in v0.11.0

func (c SummaryVec) Reset()

Reset resets its all summaries.

func (SummaryVec) WriteTo added in v0.11.0

func (c SummaryVec) WriteTo(rv map[string]int64, key string, mul, div int)

WriteTo writes it's value into given map.

type UniqueCounter added in v0.11.0

type UniqueCounter interface {
	stm.Value
	Insert(s string)
	Value() int
	Reset()
}

func NewUniqueCounter added in v0.11.0

func NewUniqueCounter(useHyperLogLog bool) UniqueCounter

type UniqueCounterVec added in v0.11.0

type UniqueCounterVec struct {
	Items map[string]UniqueCounter
	// contains filtered or unexported fields
}

func NewUniqueCounterVec added in v0.11.0

func NewUniqueCounterVec(useHyperLogLog bool) UniqueCounterVec

func (UniqueCounterVec) Get added in v0.11.0

Get gets UniqueCounter instance by name

func (UniqueCounterVec) Reset added in v0.11.0

func (c UniqueCounterVec) Reset()

func (UniqueCounterVec) WriteTo added in v0.11.0

func (c UniqueCounterVec) WriteTo(rv map[string]int64, key string, mul, div int)

WriteTo writes it's value into given map.

Jump to

Keyboard shortcuts

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