Skip to content

Commit f53ac17

Browse files
committed
Define log level constants
1 parent ae42c8e commit f53ac17

File tree

1 file changed

+22
-11
lines changed

1 file changed

+22
-11
lines changed

docs/dev.md

+22-11
Original file line numberDiff line numberDiff line change
@@ -21,36 +21,47 @@ The [k8s instrumentation logging guidelines](https://github.com/kubernetes/commu
2121
* `klog.V(4).InfoS` - Debug level verbosity
2222
* `klog.V(5).InfoS` - Trace level verbosity
2323

24+
We thus define the following constants to help choosing the level:
25+
```
26+
const(
27+
REQUIRED=0
28+
DEFAULT_MINIMAL=1
29+
DEFAULT=2
30+
VERBOSE=3
31+
DEBUG=4
32+
TRACE=5
33+
)
34+
```
2435

2536
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:
2637

2738
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
39+
* `klog.V(REQUIRED).InfoS` = `klog.InfoS` Default, log things such as startup flags
2940

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.
41+
2. Reconciler loops. The reconciler loops watch 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.
3142

32-
* `klog.V(1).InfoS`
43+
* `klog.V(DEFAULT_MINIMAL).InfoS`
3344
* Default log level in the reconcilers.
3445
* Information about config (listening on X, watching Y)
3546
* Errors that repeat frequently that relate to conditions that can be corrected (e.g., inference model not initialized yet)
36-
* `klog.V(2).InfoS`
47+
* `klog.V(DEFAULT).InfoS`
3748
* System state changing (adding/removing objects in the data store)
38-
* `V(3)` and above: Use your best judgement.
49+
* `V(VERBOSE)` and above: Use your best judgement.
3950

4051
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.
4152

42-
* `klog.V(2).InfoS`
53+
* `klog.V(DEFAULT).InfoS`
4354
* Logging HTTP requests and their exit code
4455
* Important decision making such as picking the target model, target pod
45-
* `klog.V(3).InfoS`
56+
* `klog.V(VERBOSE).InfoS`
4657
* Detailed request scheduling algorithm operations, such as running the filtering logic
47-
* `V(4)` and above: Use your best judgement.
58+
* `V(DEBUG)` and above: Use your best judgement.
4859

4960
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`
61+
* `klog.V(DEBUG).InfoS`
5162
* Transient errors/warnings, such as failure to get response from a pod.
52-
* `klog.V(5).InfoS` - Default
63+
* `klog.V(TRACE).InfoS` - For other logs.
5364

5465
5. Misc
55-
* `klog.V(3).InfoS`
66+
* `klog.V(VERBOSE).InfoS`
5667
* 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)