Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Statsd ¶
type Statsd struct {
// contains filtered or unexported fields
}
Statsd implements the Statter interface by writing StatsD formatted messages to the underlying writer.
func Dial ¶
Dial takes the same parameters as net.Dial, ie. a transport protocol (typically "udp") and an endpoint. It returns a new Statsd structure, ready to use.
Note that g2s currently performs no management on the connection it creates.
func DialWithPrefix ¶
Variant of Dial that accepts a prefix that will be prepended to the name of all buckets sent (so it can be used with services that require an API key)
func New ¶
New constructs a Statsd structure which will write statsd-protocol messages into the given io.Writer. New is intended to be used by consumers who want nonstandard behavior: for example, they may pass an io.Writer which performs buffering and aggregation of statsd-protocol messages.
Note that g2s provides no synchronization. If you pass an io.Writer which is not goroutine-safe, for example a bytes.Buffer, you must make sure you synchronize your calls to the Statter methods.
func (*Statsd) Counter ¶
Counter sends one or more counter statistics to StatsD.
Application code should call it for every potential invocation of a statistic; it uses the sampleRate to determine whether or not to send or squelch the data, on an aggregate basis.
func (*Statsd) Gauge ¶
Gauge sends one or more gauge statistics to Statsd.
Application code should call it for every potential invocation of a statistic; it uses the sampleRate to determine whether or not to send or squelch the data, on an aggregate basis.
type Statter ¶
type Statter interface { Counter(sampleRate float32, bucket string, n ...int) Timing(sampleRate float32, bucket string, d ...time.Duration) Gauge(sampleRate float32, bucket string, value ...string) }
Statter collects the ways clients can send observations to a StatsD server.
func Noop ¶
func Noop() Statter
Noop returns a struct that satisfies the Statter interface but silently ignores all Statter method invocations. It's designed to be used when normal g2s construction fails, eg.
s, err := g2s.Dial("udp", someEndpoint) if err != nil { log.Printf("not sending statistics to statsd (%s)", err) s = g2s.Noop() }