Awesome Reviewers

Reviewer · Logging

Consistent log fields and levels

Structured log entries must use field keys and severity levels that accurately reflect the data being logged, and this usage should be consistent across the codebase. Don't borrow a field name from another subsystem's domain (e.g., tagging a value as "rotationID" just to match the rotation manager's logs) when the actual value is something more generic like...

Instruction

Structured log entries must use field keys and severity levels that accurately reflect the data being logged, and this usage should be consistent across the codebase. Don’t borrow a field name from another subsystem’s domain (e.g., tagging a value as “rotationID” just to match the rotation manager’s logs) when the actual value is something more generic like a request path or name; doing so leaks implementation details and breaks if the other subsystem’s format changes. Instead, name the field for what it actually is (e.g., “path” or “name”), and only use the more specific term when the value genuinely originates from that context. Likewise, pick a log level (Error, Warn, Info, Debug) based on the actual severity of the event and apply it uniformly for similar situations (e.g., always log unexpected failures at Error, not a mix of Info/Error) so that log severity is predictable and filterable team-wide.

Example:

// Avoid: using a specialized key for a generic value
b.Logger().Error("failed to rotate root credential", "rotationID", req.Path, "err", err.Error())

// Prefer: use an accurate, self-describing key and a severity matching the event
b.Logger().Error("failed to rotate root credential", "path", req.Path, "err", err.Error())