Skip to content

Commit

Permalink
improve regexp performance in loki.process: call fmt only if debug …
Browse files Browse the repository at this point in the history
…is enabled. fix debug check
  • Loading branch information
r0ka committed Dec 27, 2024
1 parent caf4db8 commit 2a0cabf
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion internal/component/loki/process/stages/regex.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ func (r *regexStage) Process(labels model.LabelSet, extracted map[string]interfa
extracted[name] = match[i]
}
}
if level.DebugValue() {
if isDebugEnabled(r.logger) {
level.Debug(r.logger).Log("msg", "extracted data debug in regex stage", "extracted data", fmt.Sprintf("%v", extracted))
}
}
Expand All @@ -121,3 +121,7 @@ func (r *regexStage) Process(labels model.LabelSet, extracted map[string]interfa
func (r *regexStage) Name() string {
return StageTypeRegex
}

func isDebugEnabled(logger log.Logger) bool {
return level.Debug(logger).Enabled()
}

0 comments on commit 2a0cabf

Please sign in to comment.