feat(promslog): implement reserved keys, rename duplicates #746
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.
This commit adds support for "reserved" keys, where upon detecting a
duplicate log attribute key, it will rename the key to prevent
collisions/issues with core slog attribute keys in use.
The reserved keys are:
level
source
(for standard slog style)caller
(for legacy go-kit style)time
(for standard slog style)ts
(for legacy go-kit style)By supporting reserved keys, we allow users of the library to use these
keys for their own supplemental log attributes.
Fixes: #745
Example test output:
Note: this implementation only technically removes duplicates of our
core reserved keys. If a user adds multiple instances of a reserved key,
the rest get renamed to
logged_$key
, which means there could beduplicate attributes with
logged_$key
. This is mostly to simplifyimplementation so we don't need to bother reference counting in the
replace attr function to do things like
logged_$key1
,logged_$key2
,etc.
Signed-off-by: TJ Hoplock [email protected]