mirror of https://github.com/tidwall/tile38.git
Add pending_events stat
This commit is contained in:
parent
59778e6092
commit
b883f358d5
|
@ -13,6 +13,7 @@ import (
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/tidwall/buntdb"
|
||||||
"github.com/tidwall/resp"
|
"github.com/tidwall/resp"
|
||||||
"github.com/tidwall/tile38/core"
|
"github.com/tidwall/tile38/core"
|
||||||
)
|
)
|
||||||
|
@ -167,17 +168,17 @@ func (s *Server) basicStats(m map[string]interface{}) {
|
||||||
m["in_memory_size"] = sz
|
m["in_memory_size"] = sz
|
||||||
points := 0
|
points := 0
|
||||||
objects := 0
|
objects := 0
|
||||||
strings := 0
|
nstrings := 0
|
||||||
s.cols.Ascend(nil, func(v interface{}) bool {
|
s.cols.Ascend(nil, func(v interface{}) bool {
|
||||||
col := v.(*collectionKeyContainer).col
|
col := v.(*collectionKeyContainer).col
|
||||||
points += col.PointCount()
|
points += col.PointCount()
|
||||||
objects += col.Count()
|
objects += col.Count()
|
||||||
strings += col.StringCount()
|
nstrings += col.StringCount()
|
||||||
return true
|
return true
|
||||||
})
|
})
|
||||||
m["num_points"] = points
|
m["num_points"] = points
|
||||||
m["num_objects"] = objects
|
m["num_objects"] = objects
|
||||||
m["num_strings"] = strings
|
m["num_strings"] = nstrings
|
||||||
mem := readMemStats()
|
mem := readMemStats()
|
||||||
avgsz := 0
|
avgsz := 0
|
||||||
if points != 0 {
|
if points != 0 {
|
||||||
|
@ -194,6 +195,18 @@ func (s *Server) basicStats(m map[string]interface{}) {
|
||||||
m["cpus"] = runtime.NumCPU()
|
m["cpus"] = runtime.NumCPU()
|
||||||
n, _ := runtime.ThreadCreateProfile(nil)
|
n, _ := runtime.ThreadCreateProfile(nil)
|
||||||
m["threads"] = float64(n)
|
m["threads"] = float64(n)
|
||||||
|
var nevents int
|
||||||
|
s.qdb.View(func(tx *buntdb.Tx) error {
|
||||||
|
// All entries in the buntdb log are events, except for one, which
|
||||||
|
// is "hook:idx".
|
||||||
|
nevents, _ = tx.Len()
|
||||||
|
nevents -= 1 // Ignore the "hook:idx"
|
||||||
|
if nevents < 0 {
|
||||||
|
nevents = 0
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
m["pending_events"] = nevents
|
||||||
}
|
}
|
||||||
|
|
||||||
// extStats populates the passed map with extended system/go/tile38 statistics
|
// extStats populates the passed map with extended system/go/tile38 statistics
|
||||||
|
|
Loading…
Reference in New Issue