Skip to content

fix: make debug param log output work regardless of log level#1438

Merged
SuperQ merged 1 commit into
prometheus:masterfrom
tjhop:fix/restore-debug-param-logs
Jul 26, 2025
Merged

fix: make debug param log output work regardless of log level#1438
SuperQ merged 1 commit into
prometheus:masterfrom
tjhop:fix/restore-debug-param-logs

Conversation

@tjhop
Copy link
Copy Markdown
Contributor

@tjhop tjhop commented Jul 8, 2025

Fixes issue reported here:
#1381 (comment)

In aligning behavior for how the --log.prober flag is currently
expected to work, I didn't test it's effect on logs when used with the
debug URL parameter, as is often done for testing.

This changes the handler to always write to the internal buffer logger
(which is what is used to store the logs for displaying with the debug
url param), and it only writes through to the real logger if it's
enabled for the level the prober is set to. This ensures that logs are
always available with the debug param, while still correctly filtering
levels for console output at stderr.

As a consequence of thinking about how to make this work, I also
realized it wasn't necessary to manually iterate record attrs or
maintain our own attr list when hijacking the log call -- the level can
be overridden directly from the record, we just need to grab a copy via
Clone() first. So should be more efficient, as well.

Signed-off-by: TJ Hoplock t.hoplock@gmail.com

Fixes issue reported here:
prometheus#1381 (comment)

In aligning behavior for how the `--log.prober` flag is currently
expected to work, I didn't test it's effect on logs when used with the
`debug` URL parameter, as is often done for testing.

This changes the handler to always write to the internal buffer logger
(which is what is used to store the logs for displaying with the `debug`
url param), and it only writes through to the real logger if it's
enabled for the level the prober is set to. This ensures that logs are
always available with the `debug` param, while still correctly filtering
levels for console output at stderr.

As a consequence of thinking about how to make this work, I also
realized it wasn't necessary to manually iterate record attrs or
maintain our own attr list when hijacking the log call -- the level can
be overridden directly from the record, we just need to grab a copy via
Clone() first. So should be more efficient, as well.

Signed-off-by: TJ Hoplock <t.hoplock@gmail.com>
@tjhop
Copy link
Copy Markdown
Contributor Author

tjhop commented Jul 8, 2025

cc: @electron0zero @SuperQ

@tjhop
Copy link
Copy Markdown
Contributor Author

tjhop commented Jul 26, 2025

@electron0zero should we get this fix in now while we gather more input for #1377 (comment) ?

Copy link
Copy Markdown
Member

@SuperQ SuperQ left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@SuperQ SuperQ merged commit b92d156 into prometheus:master Jul 26, 2025
5 checks passed
@electron0zero
Copy link
Copy Markdown
Member

my bad for not getting to it, thanks for the PR 🙇🏼

@jesusvazquez jesusvazquez mentioned this pull request Dec 4, 2025
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.

3 participants