Cleaning up debug toolings
This commit is contained in:
@@ -183,8 +183,8 @@ func mountDebugHandler(r chi.Router, log *zap.Logger) {
|
||||
log.Debug("route debugger enabled: /__routes")
|
||||
r.Get("/__routes", debugRoutes(r))
|
||||
|
||||
log.Debug("profiler enabled: /__profiler")
|
||||
r.Mount("/__profiler", middleware.Profiler())
|
||||
log.Debug("profiler enabled: /debug/pprof")
|
||||
r.Mount("/debug", middleware.Profiler())
|
||||
|
||||
log.Debug("eventbus handlers debug enabled: /__eventbus")
|
||||
r.Get("/__eventbus", debugEventbus())
|
||||
|
||||
+17
-37
@@ -2,7 +2,6 @@ package monitor
|
||||
|
||||
import (
|
||||
"context"
|
||||
"expvar"
|
||||
"runtime"
|
||||
"time"
|
||||
|
||||
@@ -12,16 +11,16 @@ import (
|
||||
)
|
||||
|
||||
type Monitor struct {
|
||||
Alloc,
|
||||
TotalAlloc,
|
||||
Sys,
|
||||
Mallocs,
|
||||
Frees,
|
||||
LiveObjects,
|
||||
PauseTotalNs uint64
|
||||
|
||||
NumGC uint32
|
||||
NumGoroutine int
|
||||
//Alloc,
|
||||
//TotalAlloc,
|
||||
//Sys,
|
||||
//Mallocs,
|
||||
//Frees,
|
||||
//LiveObjects,
|
||||
//PauseTotalNs uint64
|
||||
//
|
||||
//NumGC uint32
|
||||
//NumGoroutine int
|
||||
}
|
||||
|
||||
var (
|
||||
@@ -52,10 +51,7 @@ func Watcher(ctx context.Context) {
|
||||
|
||||
func NewMonitor(ctx context.Context, interval time.Duration) {
|
||||
var (
|
||||
m = Monitor{}
|
||||
rtm runtime.MemStats
|
||||
goroutines = expvar.NewInt("num_goroutine")
|
||||
ticker = time.NewTicker(interval)
|
||||
ticker = time.NewTicker(interval)
|
||||
)
|
||||
|
||||
defer ticker.Stop()
|
||||
@@ -64,36 +60,20 @@ func NewMonitor(ctx context.Context, interval time.Duration) {
|
||||
select {
|
||||
case <-ticker.C:
|
||||
// Read full mem stats
|
||||
runtime.ReadMemStats(&rtm)
|
||||
|
||||
// Number of goroutines
|
||||
m.NumGoroutine = runtime.NumGoroutine()
|
||||
goroutines.Set(int64(m.NumGoroutine))
|
||||
|
||||
// Misc memory stats
|
||||
m.Alloc = rtm.Alloc
|
||||
m.TotalAlloc = rtm.TotalAlloc
|
||||
m.Sys = rtm.Sys
|
||||
m.Mallocs = rtm.Mallocs
|
||||
m.Frees = rtm.Frees
|
||||
|
||||
// Live objects = Mallocs - Frees
|
||||
m.LiveObjects = m.Mallocs - m.Frees
|
||||
|
||||
// GC Stats
|
||||
m.PauseTotalNs = rtm.PauseTotalNs
|
||||
m.NumGC = rtm.NumGC
|
||||
m := new(runtime.MemStats)
|
||||
runtime.ReadMemStats(m)
|
||||
|
||||
log.With(
|
||||
zap.Uint64("alloc", m.Alloc),
|
||||
zap.Uint64("alloc", m.HeapAlloc),
|
||||
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("liveObjects", m.Mallocs-m.Frees),
|
||||
zap.Uint64("pauseTotalNs", m.PauseTotalNs),
|
||||
zap.Uint32("numGC", m.NumGC),
|
||||
zap.Int("numGoRoutines", m.NumGoroutine),
|
||||
zap.Int("numGoRoutines", runtime.NumGoroutine()),
|
||||
).Info("tick")
|
||||
|
||||
case <-ctx.Done():
|
||||
|
||||
Reference in New Issue
Block a user