Create k8s-log-reviewer.md for logging review process#9037
Create k8s-log-reviewer.md for logging review process#9037CatherineF-dev wants to merge 1 commit into
Conversation
Add guidelines for SIG-Instrumentation logging review process, including structured and contextual logging standards, review checklist, and testing practices.
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: CatherineF-dev The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
pohly
left a comment
There was a problem hiding this comment.
This seems more targeted towards AI than humans? Just wondering.
Is it possible to do some sanity checking that this is actually producing useful reviews?
| `logcheck.conf` (see #133699, #124722, #115669). | ||
|
|
||
| ### 2. Contextual logging: thread a logger, don't proliferate `WithLogger` variants or break API. | ||
| - Prefer adding a `logger`/`ctx` parameter to a *new/unreleased* function rather than a parallel |
There was a problem hiding this comment.
That's typically not possible when converting existing code. Sometimes a new method might be coming anyway, but usually not.
| left-over logger field). A function that logs gets the convention comment | ||
| `// Contextual logging: use NewXWithLogger`. |
There was a problem hiding this comment.
| left-over logger field). A function that logs gets the convention comment | |
| `// Contextual logging: use NewXWithLogger`. | |
| left-over logger field). A function that logs initially gets the convention comment | |
| `// Contextual logging: use NewXWithLogger`, then it's callers get updated in a follow-up, PR, | |
| and then finally that comment is turned into `//logcheck:context // use NewXWithLogger ... instead` (https://github.com/kubernetes/kubernetes/issues/126379) |
| ### 8. Testing log output: use `ktesting`, isolated per-test, not the global klog logger. | ||
| - **@pohly** (#138258): ktesting-based tests are *"perfectly isolated from any other test because only | ||
| local variables are used. This is different from testing output emitted through the global klog | ||
| logger."* Prefer `k8s.io/klog/v2/ktesting` / `test/utils/ktesting`. |
There was a problem hiding this comment.
| logger."* Prefer `k8s.io/klog/v2/ktesting` / `test/utils/ktesting`. | |
| logger."* Prefer `k8s.io/kubernetes/test/utils/ktesting` over `k8s.io/klog/v2/ktesting` whever import restrictions allow it. |
| local variables are used. This is different from testing output emitted through the global klog | ||
| logger."* Prefer `k8s.io/klog/v2/ktesting` / `test/utils/ktesting`. | ||
|
|
||
| ### 9. Prefer returning an error over logging a swallowed warning. |
There was a problem hiding this comment.
| ### 9. Prefer returning an error over logging a swallowed warning. | |
| ### 9. Prefer returning an error over logging and swallowed warning. |
Add guidelines for SIG-Instrumentation logging review process, including structured and contextual logging standards, review checklist, and testing practices.
Which issue(s) this PR fixes:
Fixes #9036