-
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
promslog: Make AllowedLevel concurrency safe. #754
Conversation
Needed for prometheus/prometheus#10352 Also I renamed AllowedLevel and AllowedFormat to Level and Format. Default level (and String()) is also now 'info' not empty. It's a breaking change, but I suspect nobody was using those constructs directly, WDYT? Signed-off-by: bwplotka <[email protected]>
err := yaml.Unmarshal([]byte(``), l) | ||
if err != nil { | ||
t.Error(err) | ||
} | ||
if l.s != "" { | ||
t.Errorf("expected empty level, got %s", l.s) | ||
if got := l.String(); got != "info" { |
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 changed the behaviour purposefully. This simplifies (and optimizes) the level code.
I don't know exactly how Unmarshal and String was envisioned to be used in the YAML context. Does this blocks anyone?
type AllowedFormat struct { | ||
// Format controls a logging output format. | ||
// Not concurrency-safe. | ||
type Format struct { |
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.
As mentioned in the description - this is a breaking change, let me know if this is ok.
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.
Yes, OK this breaking change.
Any chance you would keep the old struct around and add a Deprecated
comment so downstream Go users get a linter warning?
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.
Or, maybe it's better to just drop the struct so it's a compile error.
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.
For deprecated flow we would need to maintain a behaviour which means promslog.Config
using old thing, we can but until we are v1 and this is not too painful we can break.
// Level controls a logging level, with an info default. | ||
// It wraps slog.LevelVar with string-based level control. | ||
// Level is safe to be used concurrently. | ||
type Level struct { |
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.
As mentioned in the description - this (rename) is a breaking change, let me know if this is ok.
Signed-off-by: bwplotka <[email protected]>
There are at least a few that I know of: promtheus json file logger: prom api testing blackbox exporter custom probe logging (handler.go and handler_test.go) Updates shouldn't be difficult, but a few will be needed after the breaking change |
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'm on board 👍
Needed for prometheus/prometheus#10352
Also I renamed AllowedLevel and AllowedFormat to Level and Format. Default level (and String()) is also now 'info' not empty.
It's a breaking change, but I suspect nobody was using those constructs directly, WDYT?
cc @tjhop