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.status:1|c\n"
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewCounter ¶
NewCounter returns a Counter 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.
TODO: support for sampling.
func NewGauge ¶
NewGauge returns a Gauge that emits values in the statsd protocol to the passed writer. Values are buffered for the reporting interval or until the buffer exceeds a max packet size, whichever comes first. Fields are ignored.
TODO: support for sampling.
func NewHistogram ¶
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.
Types ¶
This section is empty.