summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCatherineF-dev <yinghongfang@google.com>2021-10-13 17:05:56 -0400
committerGitHub <noreply@github.com>2021-10-13 14:05:56 -0700
commited3a7c4263662a47434a1dd5f1beddb6ddd505fc (patch)
tree2ff53218ab4be18256f78fdf0be609b3f51ecd00
parentb89bf8be9c413b0521be2f0b4eb7a6f57e44d864 (diff)
Refine sig-instrumentation devel docs (#5915)
* Updated sig-instrumentation devel docs * klog.ErrorS example Signed-off-by: Parul <parsingh@redhat.com> * add os.Exit Signed-off-by: Parul <parsingh@redhat.com> Co-authored-by: Parul <parsingh@redhat.com>
-rw-r--r--contributors/devel/sig-instrumentation/instrumentation.md4
-rw-r--r--contributors/devel/sig-instrumentation/migration-to-structured-logging.md21
2 files changed, 22 insertions, 3 deletions
diff --git a/contributors/devel/sig-instrumentation/instrumentation.md b/contributors/devel/sig-instrumentation/instrumentation.md
index b8f38e2f..478af5a0 100644
--- a/contributors/devel/sig-instrumentation/instrumentation.md
+++ b/contributors/devel/sig-instrumentation/instrumentation.md
@@ -198,11 +198,11 @@ Those pieces of information should be normalized into an info-level metric
which is always set to 1. For example:
```
-kube_pod_info{pod=...,namespace=...,pod_ip=...,host_ip=..,node=..., ...}
+kube_pod_info{pod=...,namespace=...,pod_ip=...,host_ip=..,node=..., ...} 1
```
The metric system can later denormalize those along the identifying labels
-“pod” and “namespace” labels. This leads to...
+“pod” and “namespace” labels.
## Resource Referencing
diff --git a/contributors/devel/sig-instrumentation/migration-to-structured-logging.md b/contributors/devel/sig-instrumentation/migration-to-structured-logging.md
index 3bada3ad..b6c0a18d 100644
--- a/contributors/devel/sig-instrumentation/migration-to-structured-logging.md
+++ b/contributors/devel/sig-instrumentation/migration-to-structured-logging.md
@@ -172,7 +172,7 @@ type KMetadata interface {
1. Change log functions to structured equivalent
1. Remove string formatting from log message
1. Name arguments
-1. Use `klog.KObj` and `klog.KRef` for Kubernetes object references
+1. Use `klog.KObj` and `klog.KRef` for Kubernetes objects references
1. Verify log output
## Change log functions to structured equivalent
@@ -211,6 +211,25 @@ the process, you should call `os.Exit()` yourself.
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.
+For example
+```go
+func validateFlags(cfg *config.Config, flags *pflag.FlagSet) error {
+ if err := cfg.ReadAndValidate(flags); err != nil {
+ klog.FatalF("Error in reading and validating flags %s", err)
+ os.Exit(1)
+ }
+}
+```
+should be changed to
+```go
+func validateFlags(cfg *config.Config, flags *pflag.FlagSet) error {
+ if err := cfg.ReadAndValidate(flags); err != nil {
+ klog.ErrorS(err, "Error in reading and validating flags")
+ os.Exit(1)
+ }
+}
+```
+
## Remove string formatting from log message
With structured logging, log messages are no longer formatted, leaving argument marshalling up to the logging client