Skip to content

Commit ed3a7c4

Browse files
Refine sig-instrumentation devel docs (#5915)
* Updated sig-instrumentation devel docs * klog.ErrorS example Signed-off-by: Parul <[email protected]> * add os.Exit Signed-off-by: Parul <[email protected]> Co-authored-by: Parul <[email protected]>
1 parent b89bf8b commit ed3a7c4

File tree

2 files changed

+22
-3
lines changed

2 files changed

+22
-3
lines changed

contributors/devel/sig-instrumentation/instrumentation.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,11 +198,11 @@ Those pieces of information should be normalized into an info-level metric
198198
which is always set to 1. For example:
199199

200200
```
201-
kube_pod_info{pod=...,namespace=...,pod_ip=...,host_ip=..,node=..., ...}
201+
kube_pod_info{pod=...,namespace=...,pod_ip=...,host_ip=..,node=..., ...} 1
202202
```
203203

204204
The metric system can later denormalize those along the identifying labels
205-
“pod” and “namespace” labels. This leads to...
205+
“pod” and “namespace” labels.
206206

207207
## Resource Referencing
208208

contributors/devel/sig-instrumentation/migration-to-structured-logging.md

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ type KMetadata interface {
172172
1. Change log functions to structured equivalent
173173
1. Remove string formatting from log message
174174
1. Name arguments
175-
1. Use `klog.KObj` and `klog.KRef` for Kubernetes object references
175+
1. Use `klog.KObj` and `klog.KRef` for Kubernetes objects references
176176
1. Verify log output
177177

178178
## Change log functions to structured equivalent
@@ -211,6 +211,25 @@ the process, you should call `os.Exit()` yourself.
211211

212212
Fatal calls use a default exit code of 255. When migrating, please use an exit code of 1 and include an "ACTION REQUIRED:" release note.
213213

214+
For example
215+
```go
216+
func validateFlags(cfg *config.Config, flags *pflag.FlagSet) error {
217+
if err := cfg.ReadAndValidate(flags); err != nil {
218+
klog.FatalF("Error in reading and validating flags %s", err)
219+
os.Exit(1)
220+
}
221+
}
222+
```
223+
should be changed to
224+
```go
225+
func validateFlags(cfg *config.Config, flags *pflag.FlagSet) error {
226+
if err := cfg.ReadAndValidate(flags); err != nil {
227+
klog.ErrorS(err, "Error in reading and validating flags")
228+
os.Exit(1)
229+
}
230+
}
231+
```
232+
214233
## Remove string formatting from log message
215234

216235
With structured logging, log messages are no longer formatted, leaving argument marshalling up to the logging client

0 commit comments

Comments
 (0)