Documentation ¶
Overview ¶
Package dogstatsd implements a DogStatsD backend for package metrics.
This implementation supports Datadog tags that provide additional metric filtering capabilities. See the DogStatsD documentation for protocol specifics: http://docs.datadoghq.com/guides/dogstatsd/
Index ¶
- func NewCallbackGauge(w io.Writer, key string, reportInterval, scrapeInterval time.Duration, ...)
- func NewCallbackGaugeTick(w io.Writer, key string, reportTicker, scrapeTicker <-chan time.Time, ...)
- func NewCounter(w io.Writer, key string, reportInterval time.Duration, ...) metrics.Counter
- func NewCounterTick(w io.Writer, key string, reportTicker <-chan time.Time, tags []metrics.Field) metrics.Counter
- func NewGauge(w io.Writer, key string, reportInterval time.Duration, tags []metrics.Field) metrics.Gauge
- func NewGaugeTick(w io.Writer, key string, reportTicker <-chan time.Time, tags []metrics.Field) metrics.Gauge
- func NewHistogram(w io.Writer, key string, reportInterval time.Duration, tags []metrics.Field) metrics.Histogram
- func NewHistogramTick(w io.Writer, key string, reportTicker <-chan time.Time, tags []metrics.Field) metrics.Histogram
- type Emitter
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 DogStatsD 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, globalTags []metrics.Field) metrics.Counter
NewCounter returns a Counter that emits observations in the DogStatsD protocol to the passed writer. Observations are buffered for the report interval or until the buffer exceeds a max packet size, whichever comes first.
TODO: support for sampling.
func NewCounterTick ¶
func NewCounterTick(w io.Writer, key string, reportTicker <-chan time.Time, tags []metrics.Field) 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, tags []metrics.Field) metrics.Gauge
NewGauge returns a Gauge that emits values in the DogStatsD protocol to the passed writer. Values are buffered for the report interval or until the buffer exceeds a max packet size, whichever comes first.
TODO: support for sampling.
func NewGaugeTick ¶
func NewGaugeTick(w io.Writer, key string, reportTicker <-chan time.Time, tags []metrics.Field) 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, tags []metrics.Field) metrics.Histogram
NewHistogram returns a Histogram that emits observations in the DogStatsD protocol to the passed writer. Observations are buffered for the reporting interval or until the buffer exceeds a max packet size, whichever comes first.
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(dogstatsdHistogram, time.Millisecond)
You can also enforce the constraint in a typesafe way with a millisecond TimeHistogram:
NewTimeHistogram(dogstatsdHistogram, time.Millisecond)
TODO: support for sampling.
Types ¶
type Emitter ¶
type Emitter struct {
// contains filtered or unexported fields
}
Emitter is a struct to manage connections and orchestrate the emission of metrics to a DogStatsd process.
func NewEmitter ¶
func NewEmitter(network, address string, metricsPrefix string, flushInterval time.Duration, logger log.Logger) *Emitter
NewEmitter will return an Emitter that will prefix all metrics names with the given prefix. Once started, it will attempt to create a connection with the given network and address via `net.Dial` and periodically post metrics to the connection in the DogStatsD protocol.
func NewEmitterDial ¶
func NewEmitterDial(dialer conn.Dialer, network, address string, metricsPrefix string, flushInterval time.Duration, logger log.Logger) *Emitter
NewEmitterDial is the same as NewEmitter, but allows you to specify your own Dialer function. This is primarily useful for tests.
func (*Emitter) Flush ¶
Flush will write the given buffer to a connection provided by the Emitter's connection manager.
func (*Emitter) NewCounter ¶
NewCounter returns a Counter that emits observations in the DogStatsD protocol via the Emitter's connection manager. Observations are buffered for the report interval or until the buffer exceeds a max packet size, whichever comes first. Fields are ignored.
func (*Emitter) NewGauge ¶
NewGauge returns a Gauge that emits values in the DogStatsD protocol via the the Emitter's connection manager. 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 (*Emitter) NewHistogram ¶
NewHistogram returns a Histogram that emits observations in the DogStatsD protocol via the Emitter's connection manager. 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(histogram, time.Millisecond)
You can also enforce the constraint in a typesafe way with a millisecond TimeHistogram:
NewTimeHistogram(histogram, time.Millisecond)
TODO: support for sampling.