From 64f8f105b3da231639cbc147fd76b31b7e52b14c Mon Sep 17 00:00:00 2001 From: Alex Collins Date: Tue, 5 Oct 2021 13:15:04 -0700 Subject: [PATCH] feat: log metrics labels on pod term --- runner/sidecar/sidecar.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/runner/sidecar/sidecar.go b/runner/sidecar/sidecar.go index 1a481a24..96cf23b2 100644 --- a/runner/sidecar/sidecar.go +++ b/runner/sidecar/sidecar.go @@ -221,7 +221,13 @@ func logMetrics(ctx context.Context) error { } else if g := m.Gauge; g != nil && g.Value != nil { v = g.Value } - logger.Info("metric", "name", f.GetName(), "value", v) + logger := logger.WithValues("name", f.GetName(), "value", v) + for _, p := range m.Label { + if p != nil && p.Name != nil && p.Value != nil { // paranoid check + logger = logger.WithValues(*p.Name, *p.Value) + } + } + logger.Info("metric") } } return nil