From 6e8fbe893545bbf9c2b1fceecdcc44a929c3064f Mon Sep 17 00:00:00 2001 From: Denis Arh Date: Tue, 7 May 2019 16:45:46 +0200 Subject: [PATCH] Port monitor log to zap logger --- internal/metrics/monitor.go | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/internal/metrics/monitor.go b/internal/metrics/monitor.go index 0030996dd..c4f4088c2 100644 --- a/internal/metrics/monitor.go +++ b/internal/metrics/monitor.go @@ -1,11 +1,13 @@ package metrics import ( - "encoding/json" "expvar" - "fmt" "runtime" "time" + + "go.uber.org/zap" + + "github.com/crusttech/crust/internal/logger" ) type Monitor struct { @@ -52,8 +54,18 @@ func NewMonitor(duration int) { m.PauseTotalNs = rtm.PauseTotalNs m.NumGC = rtm.NumGC - // Just encode to json and print - b, _ := json.Marshal(m) - fmt.Println(string(b)) + logger.Default(). + With( + zap.Uint64("alloc", m.Alloc), + zap.Uint64("totalAlloc", m.TotalAlloc), + zap.Uint64("sys", m.Sys), + zap.Uint64("mallocs", m.Mallocs), + zap.Uint64("frees", m.Frees), + zap.Uint64("liveObjects", m.LiveObjects), + zap.Uint64("pauseTotalNs", m.PauseTotalNs), + zap.Uint32("numGC", m.NumGC), + zap.Int("numGoRoutines", m.NumGoroutine), + ). + Debug("monitor") } }