statsd

package
v0.0.0-...-1922036 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2016 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package statsd implements a statsd backend for package metrics.

The current implementation ignores fields. In the future, it would be good to have an implementation that accepted a set of predeclared field names at construction time, and used field values to produce delimiter-separated bucket (key) names. That is,

c := NewFieldedCounter(..., "path", "status")
c.Add(1) // "myprefix.unknown.unknown:1|c\n"
c2 := c.With("path", "foo").With("status": "200")
c2.Add(1) // "myprefix.foo.200:1|c\n"

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewCallbackGauge

func NewCallbackGauge(w io.Writer, key string, reportInterval, scrapeInterval time.Duration, callback func() float64)

NewCallbackGauge emits values in the statsd protocol to the passed writer. It collects values every scrape interval from the callback. Values are buffered for the report interval or until the buffer exceeds a max packet size, whichever comes first. The report and scrape intervals may be the same. The callback determines the value, and fields are ignored, so NewCallbackGauge returns nothing.

func NewCallbackGaugeTick

func NewCallbackGaugeTick(w io.Writer, key string, reportTicker, scrapeTicker <-chan time.Time, callback func() float64)

NewCallbackGaugeTick is the same as NewCallbackGauge, but allows the user to pass in ticker channels instead of durations to control report and scrape intervals.

func NewCounter

func NewCounter(w io.Writer, key string, reportInterval time.Duration) metrics.Counter

NewCounter returns a Counter that emits observations in the statsd protocol to the passed writer. Observations are buffered for the report interval or until the buffer exceeds a max packet size, whichever comes first. Fields are ignored.

TODO: support for sampling.

func NewCounterTick

func NewCounterTick(w io.Writer, key string, reportTicker <-chan time.Time) metrics.Counter

NewCounterTick is the same as NewCounter, but allows the user to pass in a ticker channel instead of invoking time.Tick.

func NewGauge

func NewGauge(w io.Writer, key string, reportInterval time.Duration) metrics.Gauge

NewGauge returns a Gauge that emits values in the statsd protocol to the passed writer. Values are buffered for the report interval or until the buffer exceeds a max packet size, whichever comes first. Fields are ignored.

TODO: support for sampling.

func NewGaugeTick

func NewGaugeTick(w io.Writer, key string, reportTicker <-chan time.Time) metrics.Gauge

NewGaugeTick is the same as NewGauge, but allows the user to pass in a ticker channel instead of invoking time.Tick.

func NewHistogram

func NewHistogram(w io.Writer, key string, reportInterval time.Duration) metrics.Histogram

NewHistogram returns a Histogram that emits observations in the statsd protocol to the passed writer. Observations are buffered for the reporting interval or until the buffer exceeds a max packet size, whichever comes first. Fields are ignored.

NewHistogram is mapped to a statsd Timing, so observations should represent milliseconds. If you observe in units of nanoseconds, you can make the translation with a ScaledHistogram:

NewScaledHistogram(statsdHistogram, time.Millisecond)

You can also enforce the constraint in a typesafe way with a millisecond TimeHistogram:

NewTimeHistogram(statsdHistogram, time.Millisecond)

TODO: support for sampling.

func NewHistogramTick

func NewHistogramTick(w io.Writer, key string, reportTicker <-chan time.Time) metrics.Histogram

NewHistogramTick is the same as NewHistogram, but allows the user to pass a ticker channel instead of invoking time.Tick.

Types

This section is empty.

Jump to

Keyboard shortcuts

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