Skip to content

fix: respect logging levels in mongodb_exporter#6050

Open
utafrali wants to merge 2 commits intografana:mainfrom
utafrali:fix/issue-5258-mongodb-exporter-json-logs-spam-even-wit
Open

fix: respect logging levels in mongodb_exporter#6050
utafrali wants to merge 2 commits intografana:mainfrom
utafrali:fix/issue-5258-mongodb-exporter-json-logs-spam-even-wit

Conversation

@utafrali
Copy link
Copy Markdown

Describe the change:
Fixed the Enabled() method to respect logging levels. mongodb_exporter and similar libraries check Enabled() before logging to stderr, but we were always returning true which bypassed the level filter.

Detailed description:
Created a levelAwareLogger wrapper that preserves EnabledAware through log.With() chains. Now Enabled() properly delegates to the level checker instead of defaulting to true.

Which issue(s) this PR fixes: Fixes #5258

Notes for reviewers:
Simple wrapper that delegates to EnabledAware. Tests added to cover the new behavior.

Checklist: Tests updated

@utafrali utafrali requested a review from a team as a code owner April 15, 2026 01:05
@cla-assistant
Copy link
Copy Markdown

cla-assistant bot commented Apr 15, 2026

CLA assistant check
All committers have signed the CLA.

@kalleep
Copy link
Copy Markdown
Contributor

kalleep commented Apr 15, 2026

Hey thanks for the pr and I can see why the previous workarounds did not work here. But I don't want to add more wrappers.

We are currently migrating to use slog in the code base see e.g. #6039. So instead we should fix the issue by finishing this migration

@utafrali
Copy link
Copy Markdown
Author

Ah got it, I'll update this to the slog migration instead then.

@kalleep
Copy link
Copy Markdown
Contributor

kalleep commented Apr 15, 2026

Ah got it, I'll update this to the slog migration instead then.

If you want to do that it would be great but you have to wait for the pr I linked to be merged first

@utafrali
Copy link
Copy Markdown
Author

Got it, I'll wait for #6039 to merge and then update this PR with the slog migration.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MongoDB Exporter JSON logs spam even with logging level set on error

2 participants