diff --git a/.travis.yml b/.travis.yml index 2f944ba..54a8baf 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,6 +4,6 @@ go: - 1.4 install: - - go get -a github.com/cactus/go-statsd-client/statsd + - go get github.com/cactus/go-statsd-client/statsd script: make test diff --git a/Makefile b/Makefile index 22147e8..b84719e 100644 --- a/Makefile +++ b/Makefile @@ -11,7 +11,7 @@ build: *.go go build -o $(BINARY) *.go test: - go test -v ./... + go test -v run: all ./$(BINARY) diff --git a/main.go b/main.go index 789c3c2..2352d3b 100644 --- a/main.go +++ b/main.go @@ -22,8 +22,8 @@ func main() { // Create recorders and pass those to handlers. // Not sure if this is the best way to continue, but it's a point along // the process. - var client *statsd.Client - client, err := statsd.New(*statsHostPort, *statsPrefix) + var client statsd.Statter + client, err := statsd.NewClient(*statsHostPort, *statsPrefix) if err != nil { log.Fatal(err) } diff --git a/recorders.go b/recorders.go index e99bb9d..c2872b1 100644 --- a/recorders.go +++ b/recorders.go @@ -16,17 +16,19 @@ type Recorder interface { } type StatsDRecorder struct { - Client *statsd.Client + Statter statsd.Statter } // Push stats to StatsD. // This assumes that the data being written is always timing data and we are // always collecting all the samples. func (statsd StatsDRecorder) pushStat(stat string, value int64) bool { - err := statsd.Client.Timing(stat, value, 1.0) - if err != nil { - log.Fatal("there was an error sending the statsd timing", err) - return false + if statsd.Statter != nil { + err := statsd.Statter.Timing(stat, value, 1.0) + if err != nil { + log.Fatal("there was an error sending the statsd timing", err) + return false + } } return true }