-
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: new promslog and promslog/flag packages to wrap log/slog #677
Conversation
5d8a321
to
fe62144
Compare
This should be ready for review now. I believe I was able to set things up in a way where flag interactions can remain consistent (by also creating a new promslog/flag package to pair with the logger). Formatting for the literal log lines themselves should be pretty close old formatting of the logger from promlog, with the exception of the value of the Feedback welcome! |
Nice! My only question so far is how much we care about keeping the same log line formatting as before. Since this is intended for Prometheus 3.0, we can make breaking changes. Do we want to deviate from some of the minor slog defaults for formatting? Or use this as an opportunity to reset. |
We can certainly use it as an opportunity to reset -- my primary thought was that by maintaining log formatting, we would cause the least downstream disruption for anything that is parsing the resulting log lines. We're ok with making the breaking changes to formatting for prometheus because of the 3.0 release, but any other downstream projects would also inherit those formatting changes. I'd like to not be the cause of someone getting paged in the middle of the night because an upgrade to $someService was done and their loki recording/alerting rules broke from unexpected formatting changes, etc 🙃 |
So let's break this down into individual decisions:
My vote:
The other option is we add an additional formatting config/flag. |
There's also this (it made it in during a final refactor but I forgot to update commit description/PR summary):
That said, I'll cast my vote:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I'm a bit late with the discussions, but my main concern here is why would a Prometheus or prometheus exporter user decide the logging library used underneath 😬
Was there any related discussions that I've missed?
d9caec8
to
a7e4e32
Compare
I believe I've addressed all PR feedback, the only remaining item should be determining the approach we want to take on the style initialization, whether we take the constructor approach or advocate consumers use the existing methods when prepping the logger config |
You could use go's type safety to prevent library users from setting weird log styles: type LogStyle string
const (
SlogStyle LogStyle = "slog"
GoKitStyle LogStyle = "go-kit"
)
// Config is a struct containing configurable settings for the logger
type Config struct {
Level *AllowedLevel
Format *AllowedFormat
Style LogStyle
ioWriter io.Writer
} But while quickly trying this out I realized it would require to refactor the whole implementation 😵 . I'm fine with returning error from the constructor |
Hey, I'm creating a new release to unblock the UTF8 work, but I can create another release tomorrow with this PR as well :) |
Do you also need a new release ASAP to get things done in Prometheus? |
@ArthurSens @SuperQ the last commit adjusts the log style to be a custom type, it's no longer settable 👍 |
A release would be helpful whenever y'all are comfortable with the final change set and have time. For now, I'm using go workspaces to start hacking on the prometheus 3.0 conversion 🙃 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perfect!
@tjhop Do you want to squash up commits and finalize the commit/PR descriptions? |
no worries, can do 👍 |
Prereq for prometheus/prometheus#14355 This adds a new `promslog` package to create an opinionated slog logger for use within the prometheus ecosystem. By default, logs are written at `info` level and formatted to add a kv pair for the source caller. If backwards compatibility for the literal output format of the logging is required, logs can be styled in a format that is similar to how the `promlog` package formatted it's go-kit/log output [1]. The `promslog` package also makes use of an `slog.LevelVar` to dynamically adjust the level of an existing logger. Similar to the old `promlog` package, we provide means to log in `logfmt` and `json` output formats. Creating a logger is similar to the old promlog package -- optionally populate a `Config` struct, and then call `New()` with the config. In order to dynamically adjust the logger's level, retain the `Config` struct as it's own variable to access the `AllowedLevel.Set()` method, which internally updates the `AllowedLevel`'s slog.LevelVar to the desired log level. Ex: ```go config := &promslog.Config{} // Retain as variable if you need to dynamically adjust log level logger := promslog.New(config) config.Level.Set("debug") logger.Debug("your message here", "hello", "world") ``` To use go-kit style log output: ```go config := &promslog.Config{Style: promslog.GoKitStyle} // Retain as variable if you need to dynamically adjust log level logger := promslog.New(config) config.Level.Set("debug") logger.Debug("your message here", "hello", "world") ``` 1. When using the `go-kit` log style, the following changes are made to the default slog output: - adjusts slog default timestamp key from `timestamp` -> `ts` - adjusts the timestamp value to use the same time format string ("2006-01-02T15:04:05.000Z07:00") - adjusts slog default sourcecode key from `source` -> `caller` - adjusts the formatting of the sourcecode values to trim paths with `filepath.Base()`. The formatting of the sourcecode value is similar to the go-kit/log usage, with the addition of the source function in parenthesis when debug logging is enabled. Signed-off-by: TJ Hoplock <[email protected]>
a26557e
to
6ea2584
Compare
Rebased on current upstream main, squashed to a single commit, and updated the commit description/PR summary with some more accurate docs. Lemme know if you have any further thoughts 👍 |
Thanks! Merging and doing the release :) |
…6059) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [github.com/prometheus/common](https://github.com/prometheus/common) | `v0.55.0` -> `v0.57.0` | [![age](https://developer.mend.io/api/mc/badges/age/go/github.com%2fprometheus%2fcommon/v0.57.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/go/github.com%2fprometheus%2fcommon/v0.57.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/go/github.com%2fprometheus%2fcommon/v0.55.0/v0.57.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/go/github.com%2fprometheus%2fcommon/v0.55.0/v0.57.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes <details> <summary>prometheus/common (github.com/prometheus/common)</summary> ### [`v0.57.0`](https://github.com/prometheus/common/releases/tag/v0.57.0) [Compare Source](https://github.com/prometheus/common/compare/v0.56.0...v0.57.0) #### What's Changed - feat: new promslog and promslog/flag packages to wrap log/slog by [@​tjhop](https://github.com/tjhop) in [https://github.com/prometheus/common/pull/677](https://github.com/prometheus/common/pull/677) #### New Contributors - [@​tjhop](https://github.com/tjhop) made their first contribution in [https://github.com/prometheus/common/pull/677](https://github.com/prometheus/common/pull/677) **Full Changelog**: prometheus/common@v0.56.0...v0.57.0 ### [`v0.56.0`](https://github.com/prometheus/common/releases/tag/v0.56.0) [Compare Source](https://github.com/prometheus/common/compare/v0.55.0...v0.56.0) #### What's Changed - Don't always fetch a OAuth2 token, if the secret from a file didn't change by [@​multani](https://github.com/multani) in [https://github.com/prometheus/common/pull/647](https://github.com/prometheus/common/pull/647) - remove dependency to github.com/prometheus/client_golang by [@​ilius](https://github.com/ilius) in [https://github.com/prometheus/common/pull/662](https://github.com/prometheus/common/pull/662) - Bump github.com/aws/aws-sdk-go from 1.54.7 to 1.54.11 in /sigv4 by [@​dependabot](https://github.com/dependabot) in [https://github.com/prometheus/common/pull/661](https://github.com/prometheus/common/pull/661) - Synchronize common files from prometheus/prometheus by [@​prombot](https://github.com/prombot) in [https://github.com/prometheus/common/pull/664](https://github.com/prometheus/common/pull/664) - Revert [#​576](https://github.com/prometheus/common/issues/576) and add deprecation notice by [@​SuperQ](https://github.com/SuperQ) in [https://github.com/prometheus/common/pull/665](https://github.com/prometheus/common/pull/665) - Bump golang.org/x/net from 0.26.0 to 0.27.0 by [@​dependabot](https://github.com/dependabot) in [https://github.com/prometheus/common/pull/667](https://github.com/prometheus/common/pull/667) - use basic string in IsValidLegacyMetricName by [@​ywwg](https://github.com/ywwg) in [https://github.com/prometheus/common/pull/668](https://github.com/prometheus/common/pull/668) - Synchronize common files from prometheus/prometheus by [@​prombot](https://github.com/prombot) in [https://github.com/prometheus/common/pull/672](https://github.com/prometheus/common/pull/672) - Synchronize common files from prometheus/prometheus by [@​prombot](https://github.com/prombot) in [https://github.com/prometheus/common/pull/674](https://github.com/prometheus/common/pull/674) - Bump github.com/aws/aws-sdk-go from 1.54.19 to 1.55.5 in /sigv4 by [@​dependabot](https://github.com/dependabot) in [https://github.com/prometheus/common/pull/671](https://github.com/prometheus/common/pull/671) - sigv4: support nil body by [@​roidelapluie](https://github.com/roidelapluie) in [https://github.com/prometheus/common/pull/673](https://github.com/prometheus/common/pull/673) - Fix overflows of untyped int constants on 32-bit by [@​dswarbrick](https://github.com/dswarbrick) in [https://github.com/prometheus/common/pull/675](https://github.com/prometheus/common/pull/675) - Update client_golang by [@​SuperQ](https://github.com/SuperQ) in [https://github.com/prometheus/common/pull/676](https://github.com/prometheus/common/pull/676) - Update golangci lint by [@​roidelapluie](https://github.com/roidelapluie) in [https://github.com/prometheus/common/pull/679](https://github.com/prometheus/common/pull/679) - expfmt: Add UTF-8 syntax support in text_parse.go by [@​fedetorres93](https://github.com/fedetorres93) in [https://github.com/prometheus/common/pull/670](https://github.com/prometheus/common/pull/670) - Synchronize common files from prometheus/prometheus by [@​prombot](https://github.com/prombot) in [https://github.com/prometheus/common/pull/681](https://github.com/prometheus/common/pull/681) - fix(utf8): provide a method for explicitly checking label names for legacy validity by [@​ywwg](https://github.com/ywwg) in [https://github.com/prometheus/common/pull/682](https://github.com/prometheus/common/pull/682) #### New Contributors - [@​multani](https://github.com/multani) made their first contribution in [https://github.com/prometheus/common/pull/647](https://github.com/prometheus/common/pull/647) - [@​ilius](https://github.com/ilius) made their first contribution in [https://github.com/prometheus/common/pull/662](https://github.com/prometheus/common/pull/662) - [@​dswarbrick](https://github.com/dswarbrick) made their first contribution in [https://github.com/prometheus/common/pull/675](https://github.com/prometheus/common/pull/675) - [@​fedetorres93](https://github.com/fedetorres93) made their first contribution in [https://github.com/prometheus/common/pull/670](https://github.com/prometheus/common/pull/670) **Full Changelog**: prometheus/common@v0.55.0...v0.56.0 </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR is behind base branch, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR was generated by [Mend Renovate](https://mend.io/renovate/). View the [repository job log](https://developer.mend.io/github/open-telemetry/opentelemetry-go-contrib). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzOC4yNi4xIiwidXBkYXRlZEluVmVyIjoiMzguNTYuMCIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOlsiU2tpcCBDaGFuZ2Vsb2ciLCJkZXBlbmRlbmNpZXMiXX0=--> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
…5748) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [github.com/prometheus/common](https://github.com/prometheus/common) | `v0.55.0` -> `v0.57.0` | [![age](https://developer.mend.io/api/mc/badges/age/go/github.com%2fprometheus%2fcommon/v0.57.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/go/github.com%2fprometheus%2fcommon/v0.57.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/go/github.com%2fprometheus%2fcommon/v0.55.0/v0.57.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/go/github.com%2fprometheus%2fcommon/v0.55.0/v0.57.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes <details> <summary>prometheus/common (github.com/prometheus/common)</summary> ### [`v0.57.0`](https://github.com/prometheus/common/releases/tag/v0.57.0) [Compare Source](https://github.com/prometheus/common/compare/v0.56.0...v0.57.0) #### What's Changed - feat: new promslog and promslog/flag packages to wrap log/slog by [@​tjhop](https://github.com/tjhop) in [https://github.com/prometheus/common/pull/677](https://github.com/prometheus/common/pull/677) #### New Contributors - [@​tjhop](https://github.com/tjhop) made their first contribution in [https://github.com/prometheus/common/pull/677](https://github.com/prometheus/common/pull/677) **Full Changelog**: prometheus/common@v0.56.0...v0.57.0 ### [`v0.56.0`](https://github.com/prometheus/common/releases/tag/v0.56.0) [Compare Source](https://github.com/prometheus/common/compare/v0.55.0...v0.56.0) #### What's Changed - Don't always fetch a OAuth2 token, if the secret from a file didn't change by [@​multani](https://github.com/multani) in [https://github.com/prometheus/common/pull/647](https://github.com/prometheus/common/pull/647) - remove dependency to github.com/prometheus/client_golang by [@​ilius](https://github.com/ilius) in [https://github.com/prometheus/common/pull/662](https://github.com/prometheus/common/pull/662) - Bump github.com/aws/aws-sdk-go from 1.54.7 to 1.54.11 in /sigv4 by [@​dependabot](https://github.com/dependabot) in [https://github.com/prometheus/common/pull/661](https://github.com/prometheus/common/pull/661) - Synchronize common files from prometheus/prometheus by [@​prombot](https://github.com/prombot) in [https://github.com/prometheus/common/pull/664](https://github.com/prometheus/common/pull/664) - Revert [#​576](https://github.com/prometheus/common/issues/576) and add deprecation notice by [@​SuperQ](https://github.com/SuperQ) in [https://github.com/prometheus/common/pull/665](https://github.com/prometheus/common/pull/665) - Bump golang.org/x/net from 0.26.0 to 0.27.0 by [@​dependabot](https://github.com/dependabot) in [https://github.com/prometheus/common/pull/667](https://github.com/prometheus/common/pull/667) - use basic string in IsValidLegacyMetricName by [@​ywwg](https://github.com/ywwg) in [https://github.com/prometheus/common/pull/668](https://github.com/prometheus/common/pull/668) - Synchronize common files from prometheus/prometheus by [@​prombot](https://github.com/prombot) in [https://github.com/prometheus/common/pull/672](https://github.com/prometheus/common/pull/672) - Synchronize common files from prometheus/prometheus by [@​prombot](https://github.com/prombot) in [https://github.com/prometheus/common/pull/674](https://github.com/prometheus/common/pull/674) - Bump github.com/aws/aws-sdk-go from 1.54.19 to 1.55.5 in /sigv4 by [@​dependabot](https://github.com/dependabot) in [https://github.com/prometheus/common/pull/671](https://github.com/prometheus/common/pull/671) - sigv4: support nil body by [@​roidelapluie](https://github.com/roidelapluie) in [https://github.com/prometheus/common/pull/673](https://github.com/prometheus/common/pull/673) - Fix overflows of untyped int constants on 32-bit by [@​dswarbrick](https://github.com/dswarbrick) in [https://github.com/prometheus/common/pull/675](https://github.com/prometheus/common/pull/675) - Update client_golang by [@​SuperQ](https://github.com/SuperQ) in [https://github.com/prometheus/common/pull/676](https://github.com/prometheus/common/pull/676) - Update golangci lint by [@​roidelapluie](https://github.com/roidelapluie) in [https://github.com/prometheus/common/pull/679](https://github.com/prometheus/common/pull/679) - expfmt: Add UTF-8 syntax support in text_parse.go by [@​fedetorres93](https://github.com/fedetorres93) in [https://github.com/prometheus/common/pull/670](https://github.com/prometheus/common/pull/670) - Synchronize common files from prometheus/prometheus by [@​prombot](https://github.com/prombot) in [https://github.com/prometheus/common/pull/681](https://github.com/prometheus/common/pull/681) - fix(utf8): provide a method for explicitly checking label names for legacy validity by [@​ywwg](https://github.com/ywwg) in [https://github.com/prometheus/common/pull/682](https://github.com/prometheus/common/pull/682) #### New Contributors - [@​multani](https://github.com/multani) made their first contribution in [https://github.com/prometheus/common/pull/647](https://github.com/prometheus/common/pull/647) - [@​ilius](https://github.com/ilius) made their first contribution in [https://github.com/prometheus/common/pull/662](https://github.com/prometheus/common/pull/662) - [@​dswarbrick](https://github.com/dswarbrick) made their first contribution in [https://github.com/prometheus/common/pull/675](https://github.com/prometheus/common/pull/675) - [@​fedetorres93](https://github.com/fedetorres93) made their first contribution in [https://github.com/prometheus/common/pull/670](https://github.com/prometheus/common/pull/670) **Full Changelog**: prometheus/common@v0.55.0...v0.56.0 </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR is behind base branch, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR was generated by [Mend Renovate](https://mend.io/renovate/). View the [repository job log](https://developer.mend.io/github/open-telemetry/opentelemetry-go). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzOC4yNi4xIiwidXBkYXRlZEluVmVyIjoiMzguNTYuMCIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOlsiU2tpcCBDaGFuZ2Vsb2ciLCJkZXBlbmRlbmNpZXMiXX0=--> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [github.com/prometheus/common](https://github.com/prometheus/common) | `v0.56.0` -> `v0.57.0` | [![age](https://developer.mend.io/api/mc/badges/age/go/github.com%2fprometheus%2fcommon/v0.57.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/go/github.com%2fprometheus%2fcommon/v0.57.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/go/github.com%2fprometheus%2fcommon/v0.56.0/v0.57.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/go/github.com%2fprometheus%2fcommon/v0.56.0/v0.57.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes <details> <summary>prometheus/common (github.com/prometheus/common)</summary> ### [`v0.57.0`](https://github.com/prometheus/common/releases/tag/v0.57.0) [Compare Source](https://github.com/prometheus/common/compare/v0.56.0...v0.57.0) #### What's Changed - feat: new promslog and promslog/flag packages to wrap log/slog by [@​tjhop](https://github.com/tjhop) in [https://github.com/prometheus/common/pull/677](https://github.com/prometheus/common/pull/677) #### New Contributors - [@​tjhop](https://github.com/tjhop) made their first contribution in [https://github.com/prometheus/common/pull/677](https://github.com/prometheus/common/pull/677) **Full Changelog**: prometheus/common@v0.56.0...v0.57.0 </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR is behind base branch, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR was generated by [Mend Renovate](https://mend.io/renovate/). View the [repository job log](https://developer.mend.io/github/XSAM/otelsql). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzOC41Ni4wIiwidXBkYXRlZEluVmVyIjoiMzguNTYuMCIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOltdfQ==--> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [github.com/prometheus/common](https://github.com/prometheus/common) | `v0.56.0` -> `v0.57.0` | [![age](https://developer.mend.io/api/mc/badges/age/go/github.com%2fprometheus%2fcommon/v0.57.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/go/github.com%2fprometheus%2fcommon/v0.57.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/go/github.com%2fprometheus%2fcommon/v0.56.0/v0.57.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/go/github.com%2fprometheus%2fcommon/v0.56.0/v0.57.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | --- > [!WARNING] > Some dependencies could not be looked up. Check the Dependency Dashboard for more information. --- ### Release Notes <details> <summary>prometheus/common (github.com/prometheus/common)</summary> ### [`v0.57.0`](https://github.com/prometheus/common/releases/tag/v0.57.0) [Compare Source](https://github.com/prometheus/common/compare/v0.56.0...v0.57.0) #### What's Changed - feat: new promslog and promslog/flag packages to wrap log/slog by [@​tjhop](https://github.com/tjhop) in [https://github.com/prometheus/common/pull/677](https://github.com/prometheus/common/pull/677) #### New Contributors - [@​tjhop](https://github.com/tjhop) made their first contribution in [https://github.com/prometheus/common/pull/677](https://github.com/prometheus/common/pull/677) **Full Changelog**: prometheus/common@v0.56.0...v0.57.0 </details> --- ### Configuration 📅 **Schedule**: Branch creation - "on tuesday" (UTC), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR was generated by [Mend Renovate](https://mend.io/renovate/). View the [repository job log](https://developer.mend.io/github/open-telemetry/opentelemetry-collector). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzOC41OS4yIiwidXBkYXRlZEluVmVyIjoiMzguNTkuMiIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOlsiZGVwZW5kZW5jaWVzIiwicmVub3ZhdGVib3QiXX0=--> --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: opentelemetrybot <[email protected]> Co-authored-by: Yang Song <[email protected]>
This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [github.com/prometheus/common](https://github.com/prometheus/common) | `v0.56.0` -> `v0.58.0` | [![age](https://developer.mend.io/api/mc/badges/age/go/github.com%2fprometheus%2fcommon/v0.58.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/go/github.com%2fprometheus%2fcommon/v0.58.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/go/github.com%2fprometheus%2fcommon/v0.56.0/v0.58.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/go/github.com%2fprometheus%2fcommon/v0.56.0/v0.58.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes <details> <summary>prometheus/common (github.com/prometheus/common)</summary> ### [`v0.58.0`](https://github.com/prometheus/common/compare/v0.57.0...v0.58.0) [Compare Source](https://github.com/prometheus/common/compare/v0.57.0...v0.58.0) ### [`v0.57.0`](https://github.com/prometheus/common/releases/tag/v0.57.0) [Compare Source](https://github.com/prometheus/common/compare/v0.56.0...v0.57.0) #### What's Changed - feat: new promslog and promslog/flag packages to wrap log/slog by [@​tjhop](https://github.com/tjhop) in [https://github.com/prometheus/common/pull/677](https://github.com/prometheus/common/pull/677) #### New Contributors - [@​tjhop](https://github.com/tjhop) made their first contribution in [https://github.com/prometheus/common/pull/677](https://github.com/prometheus/common/pull/677) **Full Changelog**: prometheus/common@v0.56.0...v0.57.0 </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR was generated by [Mend Renovate](https://mend.io/renovate/). View the [repository job log](https://developer.mend.io/github/jaegertracing/jaeger). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzOC41OS4yIiwidXBkYXRlZEluVmVyIjoiMzguNTkuMiIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOlsiY2hhbmdlbG9nOmRlcGVuZGVuY2llcyJdfQ==--> Signed-off-by: Mend Renovate <[email protected]>
// of .999999999 which changes the timestamp from 9 variable to 3 fixed | ||
// decimals (.130 instead of .130987456). | ||
t := a.Value.Time() | ||
a.Value = slog.StringValue(t.Format("2006-01-02T15:04:05.000Z07:00")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The non-UTC timestamp format here differs from the previous promlog (go-kit) timestamp format, which used .UTC()
.
timestampFormat = log.TimestampFormat(
func() time.Time { return time.Now().UTC() },
"2006-01-02T15:04:05.000Z07:00",
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR created: #696
The Legacy promlog package will be removed in the next prometheus/common release. procfs and client_golang will also be updated transitively. prometheus/common#677 prometheus/exporter-toolkit#240
Prereq for prometheus/prometheus#14355
This adds a new
promslog
package to create an opinionated slog loggerfor use within the prometheus ecosystem. By default, logs are written at
info
level and formatted to add a kv pair for the source caller. Ifbackwards compatibility for the literal output format of the logging is
required, logs can be styled in a format that is similar to how the
promlog
package formatted it's go-kit/log output [1]. Thepromslog
package also makes use of an
slog.LevelVar
to dynamically adjust thelevel of an existing logger. Similar to the old
promlog
package, weprovide means to log in
logfmt
andjson
output formats.Creating a logger is similar to the old promlog package -- optionally
populate a
Config
struct, and then callNew()
with the config.In order to dynamically adjust the logger's level, retain the
Config
struct as it's own variable to access the
AllowedLevel.Set()
method,which internally updates the
AllowedLevel
's slog.LevelVar to thedesired log level. Ex:
To use go-kit style log output:
go-kit
log style, the following changes are made to thedefault slog output:
timestamp
->ts
("2006-01-02T15:04:05.000Z07:00")
source
->caller
filepath.Base()
. The formatting of the sourcecode value is similarto the go-kit/log usage, with the addition of the source function in
parenthesis when debug logging is enabled.
Signed-off-by: TJ Hoplock [email protected]