forked from mirrors/statsd_exporter
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()
|
tagsReceived.Inc()
|
||||||
tags := strings.Split(component, ",")
|
tags := strings.Split(component, ",")
|
||||||
for _, t := range tags {
|
for _, t := range tags {
|
||||||
t = strings.TrimPrefix(t, "#")
|
// Bail early if the tag is empty
|
||||||
kv := strings.SplitN(t, ":", 2)
|
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 {
|
if len(kv) < 2 || len(kv[1]) == 0 {
|
||||||
tagErrors.Inc()
|
tagErrors.Inc()
|
||||||
log.Debugf("Malformed or empty DogStatsD tag %s in component %s", t, component)
|
log.Debugf("Malformed or empty DogStatsD tag %s in component %s", t, component)
|
||||||
|
|
Loading…
Reference in a new issue