forked from mirrors/statsd_exporter
refactor: use structured logging
Co-authored-by: Ben Kochie <superq@gmail.com> Signed-off-by: Mark Sagi-Kazar <mark.sagikazar@gmail.com>
This commit is contained in:
parent
2852aa2a5b
commit
04bc13d73c
1 changed files with 3 additions and 6 deletions
|
@ -14,7 +14,6 @@
|
||||||
package fsm
|
package fsm
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"regexp"
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
@ -250,7 +249,7 @@ func TestIfNeedBacktracking(mappings []string, orderingDisabled bool, logger log
|
||||||
metricRe = strings.Replace(metricRe, "*", "([^.]*)", -1)
|
metricRe = strings.Replace(metricRe, "*", "([^.]*)", -1)
|
||||||
regex, err := regexp.Compile("^" + metricRe + "$")
|
regex, err := regexp.Compile("^" + metricRe + "$")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
level.Warn(logger).Log("msg", fmt.Sprintf("invalid match %s. cannot compile regex in mapping: %v", mapping, err))
|
level.Warn(logger).Log("msg", "Invalid match, cannot compile regex in mapping", "mapping", mapping, "err", err)
|
||||||
}
|
}
|
||||||
// put into array no matter there's error or not, we will skip later if regex is nil
|
// put into array no matter there's error or not, we will skip later if regex is nil
|
||||||
ruleREByLength[l] = append(ruleREByLength[l], regex)
|
ruleREByLength[l] = append(ruleREByLength[l], regex)
|
||||||
|
@ -293,8 +292,7 @@ func TestIfNeedBacktracking(mappings []string, orderingDisabled bool, logger log
|
||||||
if i2 != i1 && len(re1.FindStringSubmatchIndex(r2)) > 0 {
|
if i2 != i1 && len(re1.FindStringSubmatchIndex(r2)) > 0 {
|
||||||
// log if we care about ordering and the superset occurs before
|
// log if we care about ordering and the superset occurs before
|
||||||
if !orderingDisabled && i1 < i2 {
|
if !orderingDisabled && i1 < i2 {
|
||||||
level.Warn(logger).Log("msg", fmt.Sprintf("match \"%s\" is a super set of match \"%s\" but in a lower order, "+
|
level.Warn(logger).Log("msg", "match is a super set of match but in a lower order, the first will never be matched", "first_match", r1, "second_match", r2)
|
||||||
"the first will never be matched", r1, r2))
|
|
||||||
}
|
}
|
||||||
currentRuleNeedBacktrack = false
|
currentRuleNeedBacktrack = false
|
||||||
}
|
}
|
||||||
|
@ -312,8 +310,7 @@ func TestIfNeedBacktracking(mappings []string, orderingDisabled bool, logger log
|
||||||
}
|
}
|
||||||
|
|
||||||
if currentRuleNeedBacktrack {
|
if currentRuleNeedBacktrack {
|
||||||
level.Warn(logger).Log("msg", fmt.Sprintf("backtracking required because of match \"%s\", "+
|
level.Warn(logger).Log("msg", "backtracking required because of match. Performance may be degraded", "match", r1)
|
||||||
"matching performance may be degraded", r1))
|
|
||||||
backtrackingNeeded = true
|
backtrackingNeeded = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue