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
  • Loading branch information
r0ka committed Dec 12, 2024
1 parent b97d2b6 commit 3a41957
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ Main (unreleased)

- Use a forked `github.com/goccy/go-json` module which reduces the memory consumption of an Alloy instance by 20MB.
If Alloy is running certain otelcol components, this reduction will not apply. (@ptodev)
- improve performance in regexp component: call fmt only if debug is enabled (@r0ka)

### Bugfixes

Expand Down
4 changes: 3 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,9 @@ func (r *regexStage) Process(labels model.LabelSet, extracted map[string]interfa
extracted[name] = match[i]
}
}
level.Debug(r.logger).Log("msg", "extracted data debug in regex stage", "extracted data", fmt.Sprintf("%v", extracted))
if level.Debug(r.logger).Enabled() {
level.Debug(r.logger).Log("msg", "extracted data debug in regex stage", "extracted data", fmt.Sprintf("%v", extracted))
}
}

// Name implements Stage
Expand Down

0 comments on commit 3a41957

Please sign in to comment.