-
Notifications
You must be signed in to change notification settings - Fork 326
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
feat: add promslog.NewNopLogger()
convenience func
#697
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Simple convenience function to return an slog.Logger that writes to io.Discard. Originally suggested by @ArthurSens [here](prometheus#686 (comment)), and requested again by @bboreham [here](prometheus/prometheus#14906 (comment)). As Bryan points out in the comment, there's 147 instances where a discard logger is needed, so a consistent utility function to manage them seems helpful. Signed-off-by: TJ Hoplock <[email protected]>
tjhop
added a commit
to tjhop/prometheus
that referenced
this pull request
Sep 27, 2024
For: prometheus#14355 Requires a new release of prometheus/common to be cut, as this depends on the following PRs: prometheus/common#694 prometheus/common#697 This commit updates Prometheus to adopt stdlib's log/slog package in favor of go-kit/log. As part of converting to use slog, several other related changes are required to get prometheus working, including: - removed unused logging util func `RateLimit()` - forward ported the util/logging/Deduper logging by implementing a small custom slog.Handler that does the deduping before chaining log calls to the underlying real slog.Logger - move some of the json file logging functionality to use prom/common package functionality - refactored some of the new json file logging for scraping - changes to promql.QueryLogger interface to swap out logging methods for relevant slog sugar wrappers - updated lots of tests that used/replicated custom logging functionality, attempting to keep the logical goal of the tests consistent after the transition - added a healthy amount of `if logger == nil { $makeLogger }` type conditional checks amongst various functions where none were provided -- old code that used the go-kit/log.Logger interface had several places where there were nil references when trying to use functions like `With()` to add keyvals on the new *slog.Logger type Signed-off-by: TJ Hoplock <[email protected]>
SuperQ
approved these changes
Sep 27, 2024
tjhop
added a commit
to tjhop/snmp_exporter
that referenced
this pull request
Sep 29, 2024
Requires: prometheus/common#697 This PR includes: - Go version updates, so that `log/slog` can be used - linter updates to remove configs for `go-kit/log` that are no longer needed, and enable `sloglint` linter - Go dep updates for prometheus/{client_golang,common,exporter-toolkit} libs The bulk of this PR was automated by the following script which is being used to aid in converting the various exporters/projects to use slog: https://gist.github.com/tjhop/49f96fb7ebbe55b12deee0b0312d8434 Builds and passes tests locally with go workspaces and up-to-date main branch of prometheus/common. Signed-off-by: TJ Hoplock <[email protected]>
tjhop
added a commit
to tjhop/mysqld_exporter
that referenced
this pull request
Sep 29, 2024
Requires: prometheus/common#697 This PR includes: - linter updates to enable `sloglint` linter - Go dep updates for prometheus/{client_golang,common,exporter-toolkit} libs - refactorings to adopt log/slog in favor of go-kit/log The bulk of this PR was automated by the following script which is being used to aid in converting the various exporters/projects to use slog: https://gist.github.com/tjhop/49f96fb7ebbe55b12deee0b0312d8434 Builds and passes tests locally with go workspaces and up-to-date main branch of prometheus/common. Signed-off-by: TJ Hoplock <[email protected]>
tjhop
added a commit
to tjhop/prometheus
that referenced
this pull request
Sep 29, 2024
For: prometheus#14355 Requires a new release of prometheus/common to be cut, as this depends on the following PRs: prometheus/common#694 prometheus/common#697 This commit updates Prometheus to adopt stdlib's log/slog package in favor of go-kit/log. As part of converting to use slog, several other related changes are required to get prometheus working, including: - removed unused logging util func `RateLimit()` - forward ported the util/logging/Deduper logging by implementing a small custom slog.Handler that does the deduping before chaining log calls to the underlying real slog.Logger - move some of the json file logging functionality to use prom/common package functionality - refactored some of the new json file logging for scraping - changes to promql.QueryLogger interface to swap out logging methods for relevant slog sugar wrappers - updated lots of tests that used/replicated custom logging functionality, attempting to keep the logical goal of the tests consistent after the transition - added a healthy amount of `if logger == nil { $makeLogger }` type conditional checks amongst various functions where none were provided -- old code that used the go-kit/log.Logger interface had several places where there were nil references when trying to use functions like `With()` to add keyvals on the new *slog.Logger type Signed-off-by: TJ Hoplock <[email protected]>
tjhop
added a commit
to tjhop/prometheus
that referenced
this pull request
Sep 29, 2024
temporarily pinning prom/common to latest commit @main for access to prometheus/common#694 and prometheus/common#697 which haven't made it to a release yet Signed-off-by: TJ Hoplock <[email protected]>
tjhop
added a commit
to tjhop/prometheus
that referenced
this pull request
Sep 29, 2024
temporarily pinning prom/common to latest commit @main for access to prometheus/common#694 and prometheus/common#697 which haven't made it to a release yet Signed-off-by: TJ Hoplock <[email protected]>
tjhop
added a commit
to tjhop/prometheus
that referenced
this pull request
Sep 29, 2024
temporarily pinning prom/common to latest commit @main for access to prometheus/common#694 and prometheus/common#697 which haven't made it to a release yet Signed-off-by: TJ Hoplock <[email protected]>
tjhop
added a commit
to tjhop/memcached_exporter
that referenced
this pull request
Sep 29, 2024
Requires: prometheus/common#697 This PR includes: - linter updates to enable sloglint linter - Go dep updates for prometheus/{client_golang,common,exporter-toolkit} libs - refactorings to adopt log/slog in favor of go-kit/log The bulk of this PR was automated by the following script which is being used to aid in converting the various exporters/projects to use slog: https://gist.github.com/tjhop/49f96fb7ebbe55b12deee0b0312d8434 Builds and passes tests locally with go workspaces and up-to-date main branch of prometheus/common. Signed-off-by: TJ Hoplock <[email protected]>
SuperQ
pushed a commit
to prometheus/memcached_exporter
that referenced
this pull request
Oct 10, 2024
* ci: update to go 1.23 Signed-off-by: TJ Hoplock <[email protected]> * chore!: adopt log/slog, drop go-kit/log Requires: prometheus/common#697 This PR includes: - linter updates to enable sloglint linter - Go dep updates for prometheus/{client_golang,common,exporter-toolkit} libs - refactorings to adopt log/slog in favor of go-kit/log The bulk of this PR was automated by the following script which is being used to aid in converting the various exporters/projects to use slog: https://gist.github.com/tjhop/49f96fb7ebbe55b12deee0b0312d8434 Builds and passes tests locally with go workspaces and up-to-date main branch of prometheus/common. Signed-off-by: TJ Hoplock <[email protected]> * build(deps): bump prometheus/common to v0.60.0 Signed-off-by: TJ Hoplock <[email protected]> --------- Signed-off-by: TJ Hoplock <[email protected]>
SuperQ
pushed a commit
to prometheus/mysqld_exporter
that referenced
this pull request
Oct 10, 2024
* chore!: adopt log/slog, drop go-kit/log Requires: prometheus/common#697 This PR includes: - linter updates to enable `sloglint` linter - Go dep updates for prometheus/{client_golang,common,exporter-toolkit} libs - refactorings to adopt log/slog in favor of go-kit/log The bulk of this PR was automated by the following script which is being used to aid in converting the various exporters/projects to use slog: https://gist.github.com/tjhop/49f96fb7ebbe55b12deee0b0312d8434 Builds and passes tests locally with go workspaces and up-to-date main branch of prometheus/common. Signed-off-by: TJ Hoplock <[email protected]> * build(deps): bump prometheus/common to v0.60.0 Signed-off-by: TJ Hoplock <[email protected]> --------- Signed-off-by: TJ Hoplock <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Simple convenience function to return an slog.Logger that writes to io.Discard. Originally suggested by @ArthurSens
here, and requested again by @bboreham
here. As Bryan points out in the comment, there's 147 instances where a discard logger is needed, so a consistent utility function to manage them seems helpful.