diff --git a/dogstatsd/dogstatsd.go b/dogstatsd/dogstatsd.go index d312013..7171f62 100644 --- a/dogstatsd/dogstatsd.go +++ b/dogstatsd/dogstatsd.go @@ -10,41 +10,42 @@ import ( // Statsd is a statreceiver that writes stats to a statsd endpoint type Statsd struct { client *statsd.Client - tags []string } // New creates a new Statsd statreceiver with a new instance of a cactus statter func New(addr string, tags []string) (*Statsd, error) { - sd, err := statsd.New(addr) + sd, err := statsd.NewBuffered(addr, 10000) if err != nil { return nil, err } + sd.SkipErrors = true + sd.Tags = tags return &Statsd{ client: sd, - tags: tags, }, nil } // Checkpoint implementation that writes to statsd func (s *Statsd) Checkpoint() { - _ = s.client.Incr("kinsumer.checkpoints", s.tags, 1.0) + _ = s.client.Incr("kinsumer.checkpoints", nil, 1.0) } // EventToClient implementation that writes to statsd metrics about a record // that was consumed by the client func (s *Statsd) EventToClient(inserted, retrieved time.Time) { now := time.Now() - - _ = s.client.Incr("kinsumer.consumed", s.tags, 1.0) - _ = s.client.Timing("kinsumer.in_stream", retrieved.Sub(inserted), s.tags, 1.0) - _ = s.client.Timing("kinsumer.end_to_end", now.Sub(inserted), s.tags, 1.0) - _ = s.client.Timing("kinsumer.in_kinsumer", now.Sub(retrieved), s.tags, 1.0) + _ = s.client.Incr("kinsumer.consumed", nil, 1.0) + _ = s.client.Timing("kinsumer.in_stream", retrieved.Sub(inserted), nil, 1.0) + _ = s.client.Timing("kinsumer.end_to_end", now.Sub(inserted), nil, 1.0) + _ = s.client.Timing("kinsumer.in_kinsumer", now.Sub(retrieved), nil, 1.0) } // EventsFromKinesis implementation that writes to statsd metrics about records that // were retrieved from kinesis func (s *Statsd) EventsFromKinesis(num int, shardID string, lag time.Duration) { - shardTag := fmt.Sprintf("shardId:%s", shardID) - _ = s.client.Timing("kinsumer.lag", lag, append(s.tags, shardTag), 1.0) - _ = s.client.Count("kinsumer.retrieved", int64(num), append(s.tags, shardTag), 1.0) + tags := []string{ + fmt.Sprintf("shardId:%s", shardID), + } + _ = s.client.Timing("kinsumer.lag", lag, tags, 1.0) + _ = s.client.Count("kinsumer.retrieved", int64(num), tags, 1.0) }