-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Make API for omitting keys more approachable. #725
Conversation
Currently encoders will omit fields when encoding log entries if the key configured for that field is set to the empty string. However, this behavior isn't documented or specified explicitly as being part of the interface for encoding. This adds documentation to the `Encoder` interface that explicitly outlines the behavior that should be implemented when omitting fields.
The empty string can be used to omit a key from a log line. However, there's no explicitly exposed API for using this behavior. This cleans up the API for users by allowing them to use a constant for omitting the key instead of throwing around `""` everywhere, or making their own constant and hoping that `""` will always omit the key.
Codecov Report
@@ Coverage Diff @@
## master #725 +/- ##
=======================================
Coverage 97.43% 97.43%
=======================================
Files 40 40
Lines 2109 2109
=======================================
Hits 2055 2055
Misses 46 46
Partials 8 8
Continue to review full report at Codecov.
|
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.
Thanks for the change!
This seems pretty reasonable to me. WDYT, @prashantv @jcorbin
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.
LGTM
* Explicitly document key omission in encoding Currently encoders will omit fields when encoding log entries if the key configured for that field is set to the empty string. However, this behavior isn't documented or specified explicitly as being part of the interface for encoding. This adds documentation to the `Encoder` interface that explicitly outlines the behavior that should be implemented when omitting fields. * Add key for omission to package API The empty string can be used to omit a key from a log line. However, there's no explicitly exposed API for using this behavior. This cleans up the API for users by allowing them to use a constant for omitting the key instead of throwing around `""` everywhere, or making their own constant and hoping that `""` will always omit the key.
The way to omit keys from log lines can be more obvious to package consumers.
This addresses #724.