metrics

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2019 License: GPL-3.0 Imports: 6 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 bits 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 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 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.

Jump to

Keyboard shortcuts

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