metric

package
v0.0.0-...-481efa2 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2016 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultTimeScales = []TimeScale{scale1M, scale10M, scale1H}

DefaultTimeScales are the durations used for helpers which create windowed metrics in bulk (such as Latency or Rates).

Functions

This section is empty.

Types

type Counter

type Counter struct {
	metrics.Counter
}

A Counter holds a single mutable atomic value.

func NewCounter

func NewCounter() *Counter

NewCounter creates a counter.

func (*Counter) Each

func (c *Counter) Each(f func(string, interface{}))

Each calls the given closure with the empty string and itself.

func (*Counter) MarshalJSON

func (c *Counter) MarshalJSON() ([]byte, error)

MarshalJSON marshals to JSON.

type Gauge

type Gauge struct {
	metrics.Gauge
}

A Gauge atomically stores a single value.

func NewGauge

func NewGauge() *Gauge

NewGauge creates a Gauge.

func (*Gauge) Each

func (g *Gauge) Each(f func(string, interface{}))

Each calls the given closure with the empty string and itself.

func (*Gauge) MarshalJSON

func (g *Gauge) MarshalJSON() ([]byte, error)

MarshalJSON marshals to JSON.

type Histogram

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

A Histogram is a wrapper around an hdrhistogram.WindowedHistogram.

func NewHistogram

func NewHistogram(duration time.Duration, maxVal int64, sigFigs int) *Histogram

NewHistogram creates a new windowed HDRHistogram with the given parameters. Data is kept in the active window for approximately the given duration. See the the documentation for hdrhistogram.WindowedHistogram for details.

func (*Histogram) Current

func (h *Histogram) Current() *hdrhistogram.Histogram

Current returns a copy of the data currently in the window.

func (*Histogram) Each

func (h *Histogram) Each(f func(string, interface{}))

Each calls the closure with the empty string and the receiver.

func (*Histogram) MarshalJSON

func (h *Histogram) MarshalJSON() ([]byte, error)

MarshalJSON outputs to JSON.

func (*Histogram) RecordValue

func (h *Histogram) RecordValue(v int64)

RecordValue adds the given value to the histogram, truncating if necessary.

type Histograms

type Histograms []*Histogram

Histograms is a slice of Histogram metrics.

func (Histograms) RecordValue

func (hs Histograms) RecordValue(v int64)

RecordValue calls through to each individual Histogram.

type Iterable

type Iterable interface {
	// Each calls the given closure with each contained item.
	Each(func(string, interface{}))
}

Iterable provides a method for synchronized access to interior objects.

type Rate

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

A Rate is a exponential weighted moving average.

func NewRate

func NewRate(timescale time.Duration) *Rate

NewRate creates an EWMA rate on the given timescale. Timescales at or below 2s are illegal and will cause a panic.

func (*Rate) Add

func (e *Rate) Add(v float64)

Add adds the given measurement to the Rate.

func (*Rate) Each

func (e *Rate) Each(f func(string, interface{}))

Each calls the given closure with the empty string and the Rate's current value.

func (*Rate) MarshalJSON

func (e *Rate) MarshalJSON() ([]byte, error)

MarshalJSON marshals to JSON.

func (*Rate) Value

func (e *Rate) Value() float64

Value returns the current value of the Rate.

type Rates

type Rates struct {
	*Counter
	Rates []*Rate
}

Rates is a counter and associated EWMA backed rates at different time scales.

func (Rates) Add

func (es Rates) Add(v int64)

Add adds the given value to all contained objects.

type Registry

type Registry struct {
	sync.Mutex
	// contains filtered or unexported fields
}

A Registry bundles up various iterables (i.e. typically metrics or other registries) to provide a single point of access to them.

func NewRegistry

func NewRegistry() *Registry

NewRegistry creates a new Registry.

func (*Registry) Add

func (r *Registry) Add(format string, item Iterable) error

Add links the given Iterable into this registry using the given format string. The individual items in the registry will be formatted via fmt.Sprintf(format, <name>). As a special case, *Registry implements Iterable and can thus be added. Metric types in this package have helpers that allow them to be created and registered in a single step. Add is called manually only when adding a registry to another, or when integrating metrics defined elsewhere.

func (*Registry) Counter

func (r *Registry) Counter(name string) *Counter

Counter registers new counter to the registry.

func (*Registry) Each

func (r *Registry) Each(f func(name string, val interface{}))

Each calls the given closure for all metrics.

func (*Registry) Gauge

func (r *Registry) Gauge(name string) *Gauge

Gauge registers a new Gauge with the given name.

func (*Registry) Histogram

func (r *Registry) Histogram(name string, duration time.Duration, maxVal int64,
	sigFigs int) *Histogram

Histogram registers a new windowed HDRHistogram with the given parameters. Data is kept in the active window for approximately the given duration.

func (*Registry) Latency

func (r *Registry) Latency(prefix string) Histograms

Latency is a convenience function which registers histograms with suitable defaults for latency tracking. Values are expressed in ns, are truncated into the interval [0, time.Minute] and are recorded with two digits of precision (i.e. errors of <1ms at 100ms, <.6s at 1m). The generated names of the metric will begin with the given prefix.

TODO(mrtracy,tschottdorf): need to discuss roll-ups and generally how (and which) information flows between metrics and time series.

func (*Registry) MarshalJSON

func (r *Registry) MarshalJSON() ([]byte, error)

MarshalJSON marshals to JSON.

func (*Registry) MustAdd

func (r *Registry) MustAdd(format string, item Iterable)

MustAdd calls Add and panics on error.

func (*Registry) Rate

func (r *Registry) Rate(name string, timescale time.Duration) *Rate

Rate creates an EWMA rate over the given timescale. The comments on NewRate apply.

func (*Registry) Rates

func (r *Registry) Rates(prefix string) Rates

Rates returns a slice of EWMAs prefixed with the given name and various "standard" timescales.

type TimeScale

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

A TimeScale is a named duration.

Jump to

Keyboard shortcuts

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