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 2a0cabf commit c98025f
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions internal/component/loki/process/stages/regex.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,9 @@ func (r *regexStage) Process(labels model.LabelSet, extracted map[string]interfa
extracted[name] = match[i]
}
}
if isDebugEnabled(r.logger) {
level.Debug(r.logger).Log("msg", "extracted data debug in regex stage", "extracted data", fmt.Sprintf("%v", extracted))
}
if isDebugEnabled(r.logger) {
level.Debug(r.logger).Log("msg", "extracted data debug in regex stage", "extracted data", fmt.Sprintf("%v", extracted))
}
}

// Name implements Stage
Expand All @@ -123,5 +123,5 @@ func (r *regexStage) Name() string {
}

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

0 comments on commit c98025f

Please sign in to comment.