Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ref!: adopt log/slog + other prom configs, drop custom logging pkg #1586

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

tjhop
Copy link

@tjhop tjhop commented Dec 3, 2024

I would call this a breaking change, as there are updates to command line flag interactions.

Changes included:

  • convert --debug bool flag -> --log.level string flag. this aligns with prom conventions. This project uses urfave/cli for application commands/flags rather than kingpin as other go packages do, so I couldn't use the promslog/flag pkg directly. Rather, I use our upstream promslog/kingpin configs in the configs we pass here for urfave/cli. We can decide to move off urfave/cli and/or adopt kingpin in the future.
  • removes pkg/logging in favor of using prometheus/common/promslog. A small utility function is included in main to simplify some boilerplate with logger initialization, since we instantiate in main in a few places. All functions have been converted to accept/use *slog.Loggers rather than the custom logger interface.
  • the removal of the custom logging pkg also removes the IsDebugEnabled() method, but this is fine because the logger is leveled; debug logs will not print unless --log.level debug is passed at the command line, there is no need to check if debug is enabled at log time in the vast majority of cases.
  • Updates tests as needed; updates nop loggers, test signatures that used IsDebugEnabled(), etc.
  • enable sloglint in golangci-lint, remove go-kit/log configs

I would call this a breaking change, as there are updates to command
line flag interactions.

Changes included:
- convert `--debug` bool flag -> `--log.level` string flag. this aligns
  with prom conventions. This project uses urfave/cli for application
commands/flags rather than kingpin as other go packages do, so I
couldn't use the promslog/flag pkg directly. Rather, I use our upstream
promslog/kingpin configs in the configs we pass here for urfave/cli. We
can decide to move off urfave/cli and/or adopt kingpin in the future.
- removes `pkg/logging` in favor of using `prometheus/common/promslog`.
  A small utility function is included in main to simplify some
boilerplate with logger initialization, since we instantiate in main in
a few places. All functions have been converted to accept/use
*slog.Loggers rather than the custom logger interface.
- the removal of the custom logging pkg also removes the
  `IsDebugEnabled()` method, but this is fine because the logger is
leveled; debug logs will not print unless `--log.level debug` is passed
at the command line, there is no need to check if debug is enabled at
log time in the vast majority of cases.
- Updates tests as needed; updates nop loggers, test signatures that
  used `IsDebugEnabled()`, etc.
- enable sloglint in golangci-lint, remove go-kit/log configs

Signed-off-by: TJ Hoplock <[email protected]>
@tjhop
Copy link
Author

tjhop commented Dec 3, 2024

Supercedes #1577

cc: @SuperQ

@SuperQ
Copy link
Contributor

SuperQ commented Dec 3, 2024

Thanks, we'll probably slowly convert over other things like urfave/cli to Prometheus community normal components over time.

Copy link
Contributor

@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.

Great work!

@tjhop
Copy link
Author

tjhop commented Dec 4, 2024

Looking into the config verification failure in tests

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.

2 participants