Merge pull request #1768 from influxdata/dgn-speedup-statsd-parser

speed up statsd parser
This commit is contained in:
David Norton 2016-09-15 10:46:56 -04:00 committed by GitHub
commit b613405f42
2 changed files with 12 additions and 1 deletions

View File

@ -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]

View File

@ -85,6 +85,8 @@ type Statsd struct {
Templates []string
listener *net.UDPConn
graphiteParser *graphite.GraphiteParser
}
// One statsd metric, form is <bucket>:<value>|<mtype>|@<samplerate>
@ -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)