From 17a6fefc3b4b8de08661f706545e289453001120 Mon Sep 17 00:00:00 2001 From: Cooper Lees Date: Thu, 25 Sep 2014 08:34:27 -0700 Subject: [PATCH] Go routine stat --- http/routes.go | 3 +++ stats/stats.go | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/http/routes.go b/http/routes.go index dbc0eeb..925e591 100644 --- a/http/routes.go +++ b/http/routes.go @@ -9,6 +9,7 @@ import ( "io/ioutil" "net/http" "net/url" + "runtime" "github.com/julienschmidt/httprouter" @@ -43,6 +44,8 @@ func (s *Server) stats(w http.ResponseWriter, r *http.Request, p httprouter.Para var val interface{} query := r.URL.Query() + stats.DefaultStats.GoRoutines = runtime.NumGoroutine() + if _, flatten := query["flatten"]; flatten { val = stats.DefaultStats.Flattened() } else { diff --git a/stats/stats.go b/stats/stats.go index 44a788e..49df774 100644 --- a/stats/stats.go +++ b/stats/stats.go @@ -73,6 +73,8 @@ type Stats struct { ConnectionsAccepted uint64 `json:"Connections.Accepted"` BytesTransmitted uint64 `json:"BytesTransmitted"` + GoRoutines int `json:"Runtime.GoRoutines"` + RequestsHandled uint64 `json:"Requests.Handled"` RequestsErrored uint64 `json:"Requests.Errored"` ClientErrors uint64 `json:"Requests.Bad"` @@ -105,6 +107,8 @@ func New(cfg config.StatsConfig) *Stats { Started: time.Now(), events: make(chan int, cfg.BufferSize), + GoRoutines: 0, + ipv4PeerEvents: make(chan int, cfg.BufferSize), ipv6PeerEvents: make(chan int, cfg.BufferSize), responseTimeEvents: make(chan time.Duration, cfg.BufferSize),