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 c98025f commit 54a4a29
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions 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 isDebugEnabled(r.logger) {
if Debug {
level.Debug(r.logger).Log("msg", "extracted data debug in regex stage", "extracted data", fmt.Sprintf("%v", extracted))
}
}
Expand All @@ -121,7 +121,3 @@ 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.AllowDebug().Enabled(logger)
}

0 comments on commit 54a4a29

Please sign in to comment.