Skip to content

Commit

Permalink
refactor: use structured logging
Browse files Browse the repository at this point in the history
Co-authored-by: Ben Kochie <superq@gmail.com>
Signed-off-by: Mark Sagi-Kazar <mark.sagikazar@gmail.com>
  • Loading branch information
sagikazarmark and SuperQ committed Jun 9, 2021
1 parent 2852aa2 commit a7ec61b
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions pkg/mapper/fsm/fsm.go
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ func TestIfNeedBacktracking(mappings []string, orderingDisabled bool, logger log
metricRe = strings.Replace(metricRe, "*", "([^.]*)", -1)
regex, err := regexp.Compile("^" + metricRe + "$")
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
ruleREByLength[l] = append(ruleREByLength[l], regex)
Expand Down Expand Up @@ -293,8 +293,7 @@ func TestIfNeedBacktracking(mappings []string, orderingDisabled bool, logger log
if i2 != i1 && len(re1.FindStringSubmatchIndex(r2)) > 0 {
// log if we care about ordering and the superset occurs before
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, "+
"the first will never be matched", r1, r2))
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)
}
currentRuleNeedBacktrack = false
}
Expand All @@ -312,8 +311,7 @@ func TestIfNeedBacktracking(mappings []string, orderingDisabled bool, logger log
}

if currentRuleNeedBacktrack {
level.Warn(logger).Log("msg", fmt.Sprintf("backtracking required because of match \"%s\", "+
"matching performance may be degraded", r1))
level.Warn(logger).Log("msg", "backtracking required because of match. Performance may be degraded", "match", r1)
backtrackingNeeded = true
}
}
Expand Down

0 comments on commit a7ec61b

Please sign in to comment.