From c98025fdf1a19862cacbcd70b8488e687e56d6be Mon Sep 17 00:00:00 2001 From: Roman Karpenko Date: Fri, 27 Dec 2024 17:44:50 +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 | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/internal/component/loki/process/stages/regex.go b/internal/component/loki/process/stages/regex.go index 5e1b41a40..f734545ac 100644 --- a/internal/component/loki/process/stages/regex.go +++ b/internal/component/loki/process/stages/regex.go @@ -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 @@ -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) }