Skip to content

Commit ae42c8e

Browse files
committed
Add logging guidelines
1 parent 1ad93e4 commit ae42c8e

File tree

2 files changed

+57
-1
lines changed

2 files changed

+57
-1
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ Our community meeting is weekly at Th 10AM PDT; [zoom link here](https://zoom.us
3434

3535
We currently utilize the [#wg-serving](https://kubernetes.slack.com/?redir=%2Fmessages%2Fwg-serving) slack channel for communications.
3636

37-
Contributions are readily welcomed, thanks for joining us!
37+
Contributions are readily welcomed, follow the [dev guide](./docs/dev.md) to start contributing!
3838

3939
### Code of conduct
4040

docs/dev.md

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
<!-- Dev guide -->
2+
3+
4+
## Logging
5+
6+
### Change log verbosity
7+
We use the `k8s.io/klog/v2` package to manage logging.
8+
9+
We generally follow the [k8s instrumentation logging guidelines](https://github.com/kubernetes/community/blob/master/contributors/devel/sig-instrumentation/logging.md), which states "the practical default level is V(2). Developers and QE environments may wish to run at V(3) or V(4)".
10+
11+
To configure logging verbosity, specify the `v` flag such as `--v=2`.
12+
13+
### Add logs
14+
15+
The [k8s instrumentation logging guidelines](https://github.com/kubernetes/community/blob/master/contributors/devel/sig-instrumentation/logging.md) has the following definitions:
16+
17+
* `klog.V(0).InfoS` = `klog.InfoS` - Generally useful for this to **always** be visible to a cluster operator
18+
* `klog.V(1).InfoS` - A reasonable default log level if you don't want verbosity.
19+
* `klog.V(2).InfoS` - Useful steady state information about the service and important log messages that may correlate to significant changes in the system. This is the recommended default log level for most systems.
20+
* `klog.V(3).InfoS` - Extended information about changes
21+
* `klog.V(4).InfoS` - Debug level verbosity
22+
* `klog.V(5).InfoS` - Trace level verbosity
23+
24+
25+
The guidelines are written in the context of a k8s controller. Our [ext-proc](../pkg/ext-proc/) does more things such as handling requests and scraping metrics, therefore we adapt the guidelines as follows:
26+
27+
1. The server startup process. Logging at the default verbosity level is generally welcome here as this is only logged once at startup, and provides useful info for debugging.
28+
* `klog.V(0).InfoS` = `klog.InfoS` Default, log things such as startup flags
29+
30+
2. Reconciler loops. The reconciler loops watches for CR changes such as the `InferenceModel` CR. And given changes in these CRs significantly affect the behavior of the extension, we recommend using v=1 verbosity level as default, and sparsely use higher verbosity levels.
31+
32+
* `klog.V(1).InfoS`
33+
* Default log level in the reconcilers.
34+
* Information about config (listening on X, watching Y)
35+
* Errors that repeat frequently that relate to conditions that can be corrected (e.g., inference model not initialized yet)
36+
* `klog.V(2).InfoS`
37+
* System state changing (adding/removing objects in the data store)
38+
* `V(3)` and above: Use your best judgement.
39+
40+
3. Inference request handling. These requests are expected to be much higher volume than the control flow in the reconcilers and therefore we should be mindful of log spamming. We recommend using v=2 to log important info about a request, such as the HTTP response code, and higher verbosity levels for less important info.
41+
42+
* `klog.V(2).InfoS`
43+
* Logging HTTP requests and their exit code
44+
* Important decision making such as picking the target model, target pod
45+
* `klog.V(3).InfoS`
46+
* Detailed request scheduling algorithm operations, such as running the filtering logic
47+
* `V(4)` and above: Use your best judgement.
48+
49+
4. Metric scraping loops. These loops run at a very high frequency, and logs can be very spammy if not handled properly.
50+
* `klog.V(4).InfoS`
51+
* Transient errors/warnings, such as failure to get response from a pod.
52+
* `klog.V(5).InfoS` - Default
53+
54+
5. Misc
55+
* `klog.V(3).InfoS`
56+
* A periodically (every 5s) printed debug message with the current pods and metrics. This is very important to debug the request scheduling algorithm, and yet not spammy compared to the metric scraping loop logs.

0 commit comments

Comments
 (0)