speed up statsd parser

This commit is contained in:
David Norton 2016-09-14 13:32:43 -04:00
parent 0f0ab953f6
commit e999298078
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)