From 54a4a29f8624235b80255ad494eaf2bf65879298 Mon Sep 17 00:00:00 2001 From: Roman Karpenko Date: Fri, 27 Dec 2024 17:58:03 +0200 Subject: [PATCH] improve regexp performance in `loki.process`: call fmt only if debug is enabled. fix debug check --- internal/component/loki/process/stages/regex.go | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/internal/component/loki/process/stages/regex.go b/internal/component/loki/process/stages/regex.go index f734545ac..42625f2ce 100644 --- a/internal/component/loki/process/stages/regex.go +++ b/internal/component/loki/process/stages/regex.go @@ -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)) } } @@ -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) -}