Emit GC metrics at flush time.
@@ -10,6 +10,7 @@ import (
"net"
"net/http"
"net/url"
+ "runtime"
"strconv"
"strings"
"sync"
@@ -282,6 +283,13 @@ func (s *Server) flushRemote(ctx context.Context, finalMetrics []samplers.DDMetr
span, _ := trace.StartSpanFromContext(ctx, "")
defer span.Finish()
+ mem := &runtime.MemStats{}
+ runtime.ReadMemStats(mem)
+
+ s.Statsd.Gauge("mem.heap_alloc_bytes", float64(mem.HeapAlloc), nil, 1.0)
+ s.Statsd.Gauge("gc.number", float64(mem.NumGC), nil, 1.0)
+ s.Statsd.Gauge("gc.pause_total_ns", float64(mem.PauseTotalNs), nil, 1.0)
+
s.Statsd.Gauge("flush.post_metrics_total", float64(len(finalMetrics)), nil, 1.0)
// Check to see if we have anything to do
if len(finalMetrics) == 0 {
