Documentation ¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func New ¶
New creasted a SinkFactory which is used to create Sinks sending data to a UDP statsd server Provide a UDP address, a prefix and a maximum UDP datagram size. 1432 should be a safe size for most nets.
Example ¶
package main import ( "github.com/One-com/gone/metric" "github.com/One-com/gone/metric/sink/statsd" "log" "os" "time" ) func main() { var sink metric.Sink var err error sink, err = statsd.New( statsd.Buffer(512), statsd.Output(os.Stdout), statsd.Prefix("prefix")) if err != nil { log.Fatal(err) } gauge := metric.NewGauge("gauge") counter := metric.NewCounter("counter") histo := metric.NewHistogram("histo") timer := metric.NewTimer("timer") set := metric.NewSet("set") timer.Sample(time.Second) timer.Sample(time.Millisecond) gauge.Set(17) histo.Sample(123456) counter.Inc(2) counter.Inc(3) set.Add("member") set.Add("member") timer.FlushReading(sink) gauge.FlushReading(sink) counter.FlushReading(sink) histo.FlushReading(sink) set.FlushReading(sink) sink.Flush() }
Output: prefix.timer:1000|ms prefix.timer:1|ms prefix.gauge:17|g prefix.counter:5|c prefix.histo:123456|ms prefix.set:member|s
Types ¶
type Option ¶
Option is the type of configuration options for the statsd sink factory.
func Buffer ¶
Buffer sets the package size with which writes to the underlying io.Writer (often an UDPConn) is done.
type Sink ¶
type Sink struct {
// contains filtered or unexported fields
}
Sink is a go-routine safe version of a Statsd sink. Call UnlockedSink() to get a faster, but not go-routine safe Sink.
func (*Sink) RecordNumeric64 ¶
Record a Numeric64 value with the sink
func (*Sink) UnlockedSink ¶
Click to show internal directories.
Click to hide internal directories.