Skip to content

Commit

Permalink
update for latest statsd client lib
Browse files Browse the repository at this point in the history
  • Loading branch information
lanyonm committed Mar 23, 2015
1 parent 0e00a06 commit 80b1d98
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ build: *.go
go build -o $(BINARY) *.go

test:
go test -v ./...
go test -v

run: all
./$(BINARY)
Expand Down
4 changes: 2 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
12 changes: 7 additions & 5 deletions recorders.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit 80b1d98

Please sign in to comment.