Documentation ¶
Index ¶
Constants ¶
const (
MAX_PACKET_SIZE = 65536 - 8 - 20 // 8-byte UDP header, 20-byte IP header
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
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) }
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 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 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() }