Use constants for structured logging field names #252
Labels
good first issue
Good for newcomers
kind/task
Tasks, chores, etc
optimization
Optimization of existing feature
Milestone
Is your task related to a problem? Please describe.
We use structured logging to help log ingestion tools filter information. However, the names we use for the structured fields are given as string literals and are inconsistent, all over the place, and leave much room for more inconsistency in the future. We probably also use some fields that are either redundant, or not required. Then, we use a stupid idiom of having a
log()
function per package that returns a logrus entry we use as a starting point for logging.Describe the solution you'd like
We should go through all packages and see a) whether all field names make sense and remove those that don't and b) replace the package's
log()
function by using a more central function (in its own package).We should replace the string literals for fields by centrally defined constants to define the available and valid field names for structured logging. This will help gaining some consistency and will improve user experience.
The available fields should be pointed to in the logging section of the contributor's documentation, along with a note that people must not use string literals for fields but rather introduce a new constant.
Describe alternatives you've considered
Additional context
The text was updated successfully, but these errors were encountered: