Skip to content

GoMetric/go-statsd-client

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

52 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

go-statsd-client

Client for StatsD (Golang)

Go Report Card GoDoc Build Status Code Climate

Installation

go get -u github.com/GoMetric/go-statsd-client

Usage

Client may be in buffered and unbuffered mode.

In buffered mode adding metric only adds it to buffer. Then client.Flush() builds all metrics to packed and sends them to StatsD server by one request.

In unbuffered mode each metric sends to StatsD immediately.

Creating unbuffered client:

client := NewClient("127.0.0.1", 9876)  # create client
client.Open()                           # open connection to StatsD
client.Count("a.b.c", 42, 0.7)          # set count metric and send it to StatsD

Creating buffered client:

client := NewBufferedClient("127.0.0.1", 9876) # create client
client.Open()                                  # open connection to StatsD
client.Count("a.b.c", 42, 0.7)                 # set count metric and add it to buffer
client.Timing("a.b.d", 43)                     # set timing metric and add it to buffer
client.Flush()                                 # send all metrics as one packet to StatsD

Add metric prefix to all keys:

client := NewBufferedClient("127.0.0.1", 9876) # create client
client.SetPrefix("prefix")                     # set prefix to all keys
client.Open()                                  # open connection to StatsD
client.Count("a.b.c", 42, 0.7)                 # set count metric "prefix.a.b.c" and add it to buffer
client.Timing("a.b.d", 43)                     # set timing metric "prefix.a.b.d" and add it to buffer
client.Flush()                                 # send all metrics as one packet to StatsD

See also