mirror of
https://github.com/prometheus/statsd_exporter.git
synced 2024-11-26 09:11:01 +00:00
Replace TrimPrefix w/special purpose implementation
On the a-z benchmark, this brings the ns/op down from 5658 to 5533. Signed-off-by: Clayton O'Neill <claytono@github.com>
This commit is contained in:
parent
9cd711ed3e
commit
052beaa3ac
1 changed files with 11 additions and 2 deletions
13
exporter.go
13
exporter.go
|
@ -589,9 +589,18 @@ func parseDogStatsDTagsToLabels(component string) map[string]string {
|
|||
tagsReceived.Inc()
|
||||
tags := strings.Split(component, ",")
|
||||
for _, t := range tags {
|
||||
t = strings.TrimPrefix(t, "#")
|
||||
kv := strings.SplitN(t, ":", 2)
|
||||
// Bail early if the tag is empty
|
||||
if len(t) == 0 {
|
||||
tagErrors.Inc()
|
||||
log.Debugf("Empty tag found in '%s'", component)
|
||||
continue
|
||||
}
|
||||
// Skip hash if found.
|
||||
if t[0] == '#' {
|
||||
t = t[1:]
|
||||
}
|
||||
|
||||
kv := strings.SplitN(t, ":", 2)
|
||||
if len(kv) < 2 || len(kv[1]) == 0 {
|
||||
tagErrors.Inc()
|
||||
log.Debugf("Malformed or empty DogStatsD tag %s in component %s", t, component)
|
||||
|
|
Loading…
Reference in a new issue