-
Notifications
You must be signed in to change notification settings - Fork 16
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
pkg/logger/lk: new package for log key glossary #986
base: main
Are you sure you want to change the base?
Conversation
What is the intended use of the keys from logkey? Is this for labelling with ZAP's zap.String(key, value) construction, or is it for arbitrary string / int constants that can be used for logging in a centralized way? |
We don't typically use the zap field API like that, but that would be valid. More often we just call the |
I see, so are you planning to extract all the possible keys in some kind of automatic way? Or would you just keep adding them here continuously? |
We could try to start with some automation, but adding keys manually would be sufficient for most common inconsistencies. I did consider providing zap field support as well, but I'm not sure how that should work. Even just |
Sound good. Thanks for explaining! |
pkg/logger/logkey/logkey.go
Outdated
const ( | ||
ChainID = "chainID" // string | ||
ContractID = "contractID" // string | ||
FeedID = "feedID" // string - hex-encoded 32-byte value, prefixed with "0x", all lowercase |
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.
Perhaps lowercase is needlessly strict? I copied this from a type FeedID string
.
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 it is fine either way. What exactly do you mean by strict? I.e., in which situation lower case is better/worse than the upper case?
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 mean that it seems superficial to expect/enforce that we use only lowercase. It is trivial to convert to only lowercase at the call site if that is what you need, and it could be a big pain to chase around all the cases and align them as lower case. Perhaps filtering logs is easier with all lowercase? That might be worth it.
@@ -112,12 +113,12 @@ func (a *dataFeedsAggregator) Aggregate(lggr logger.Logger, previousOutcome *typ | |||
previousReportInfo := currentState.FeedInfo[feedIDStr] | |||
feedID, err2 := datastreams.NewFeedID(feedIDStr) | |||
if err2 != nil { | |||
lggr.Errorw("could not convert %s to feedID", "feedID", feedID) | |||
lggr.Errorw("could not convert %s to feedID", logkey.FeedID, feedID) |
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.
Is logkey
the best package name? We might want to use these with Prometheus too, and so we could generalize and shorten to just keys
:
lggr.Errorw("could not convert %s to feedID", logkey.FeedID, feedID) | |
lggr.Errorw("could not convert %s to feedID", keys.FeedID, feedID) |
But this would have name collisions in some places.
Something like labels
is perhaps less collision prone, but more verbose:
lggr.Errorw("could not convert %s to feedID", logkey.FeedID, feedID) | |
lggr.Errorw("could not convert %s to feedID", labels.FeedID, feedID) |
Any other ideas?
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.
logconst or logentry?
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 it would need to be fewer than 6 characters to be an improvement on logkey
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.
logval or logdef ?
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.
Would package lk
be too opaque? Typically they should be meaningful, but in this case the usage should always make it clear 🤔 It would also make aliasing packages less obnoxious (chainlk
, caplk
, etc.)
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.
Update to package lk
to try it out. I think I like it.
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.
discussed offline.
to move forward, agree to keep this simple and audit the growth/ussage of the package with intent to mv/refactor if it becomes too ungainly
This PR introduces a new
package logkey
to serve as a glossary of logger keys in order to align common fields.Supports: