mirror of
https://github.com/sot-tech/mochi.git
synced 2026-05-14 13:08:36 -07:00
Go routine stat
This commit is contained in:
@@ -9,6 +9,7 @@ import (
|
|||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
"runtime"
|
||||||
|
|
||||||
"github.com/julienschmidt/httprouter"
|
"github.com/julienschmidt/httprouter"
|
||||||
|
|
||||||
@@ -43,6 +44,8 @@ func (s *Server) stats(w http.ResponseWriter, r *http.Request, p httprouter.Para
|
|||||||
var val interface{}
|
var val interface{}
|
||||||
query := r.URL.Query()
|
query := r.URL.Query()
|
||||||
|
|
||||||
|
stats.DefaultStats.GoRoutines = runtime.NumGoroutine()
|
||||||
|
|
||||||
if _, flatten := query["flatten"]; flatten {
|
if _, flatten := query["flatten"]; flatten {
|
||||||
val = stats.DefaultStats.Flattened()
|
val = stats.DefaultStats.Flattened()
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -73,6 +73,8 @@ type Stats struct {
|
|||||||
ConnectionsAccepted uint64 `json:"Connections.Accepted"`
|
ConnectionsAccepted uint64 `json:"Connections.Accepted"`
|
||||||
BytesTransmitted uint64 `json:"BytesTransmitted"`
|
BytesTransmitted uint64 `json:"BytesTransmitted"`
|
||||||
|
|
||||||
|
GoRoutines int `json:"Runtime.GoRoutines"`
|
||||||
|
|
||||||
RequestsHandled uint64 `json:"Requests.Handled"`
|
RequestsHandled uint64 `json:"Requests.Handled"`
|
||||||
RequestsErrored uint64 `json:"Requests.Errored"`
|
RequestsErrored uint64 `json:"Requests.Errored"`
|
||||||
ClientErrors uint64 `json:"Requests.Bad"`
|
ClientErrors uint64 `json:"Requests.Bad"`
|
||||||
@@ -105,6 +107,8 @@ func New(cfg config.StatsConfig) *Stats {
|
|||||||
Started: time.Now(),
|
Started: time.Now(),
|
||||||
events: make(chan int, cfg.BufferSize),
|
events: make(chan int, cfg.BufferSize),
|
||||||
|
|
||||||
|
GoRoutines: 0,
|
||||||
|
|
||||||
ipv4PeerEvents: make(chan int, cfg.BufferSize),
|
ipv4PeerEvents: make(chan int, cfg.BufferSize),
|
||||||
ipv6PeerEvents: make(chan int, cfg.BufferSize),
|
ipv6PeerEvents: make(chan int, cfg.BufferSize),
|
||||||
responseTimeEvents: make(chan time.Duration, cfg.BufferSize),
|
responseTimeEvents: make(chan time.Duration, cfg.BufferSize),
|
||||||
|
|||||||
Reference in New Issue
Block a user