Skip to content

Commit

Permalink
speed up statsd parser
Browse files Browse the repository at this point in the history
  • Loading branch information
dgnorton committed Sep 15, 2016
1 parent 0f0ab95 commit e999298
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
- [#1716](https://github.com/influxdata/telegraf/issues/1716): Sensors plugin strconv.ParseFloat: parsing "": invalid syntax
- [#1530](https://github.com/influxdata/telegraf/issues/1530): Fix prometheus_client reload panic
- [#1764](https://github.com/influxdata/telegraf/issues/1764): Fix kafka consumer panic when nil error is returned down errs channel.
- [#1768](https://github.com/influxdata/telegraf/pull/1768): Speed up statsd parsing.

## v1.0 [2016-09-08]

Expand Down
12 changes: 11 additions & 1 deletion plugins/inputs/statsd/statsd.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ type Statsd struct {
Templates []string

listener *net.UDPConn

graphiteParser *graphite.GraphiteParser
}

// One statsd metric, form is <bucket>:<value>|<mtype>|@<samplerate>
Expand Down Expand Up @@ -505,7 +507,15 @@ func (s *Statsd) parseName(bucket string) (string, string, map[string]string) {

var field string
name := bucketparts[0]
p, err := graphite.NewGraphiteParser(s.MetricSeparator, s.Templates, nil)

p := s.graphiteParser
var err error

if p == nil || s.graphiteParser.Separator != s.MetricSeparator {
p, err = graphite.NewGraphiteParser(s.MetricSeparator, s.Templates, nil)
s.graphiteParser = p
}

if err == nil {
p.DefaultTags = tags
name, tags, field, _ = p.ApplyTemplate(name)
Expand Down

0 comments on commit e999298

Please sign in to comment.