feat: add IM service health and metrics endpoints

This commit is contained in:
richjohnrambo
2026-09-09 14:24:40 +08:00
parent 4c9bdd64e0
commit 9159ec7fc7
11 changed files with 616 additions and 6 deletions
+9
View File
@@ -77,18 +77,27 @@ func statsInit(mux *http.ServeMux, path string) {
func statsRegisterDbStats() {
if f := store.Store.DbStats(); f != nil {
if expvar.Get("DbStats") != nil {
return
}
expvar.Publish("DbStats", expvar.Func(f))
}
}
// Register integer variable. Don't check for initialization.
func statsRegisterInt(name string) {
if expvar.Get(name) != nil {
return
}
expvar.Publish(name, new(expvar.Int))
}
// Register histogram variable. `bounds` specifies histogram buckets/bins
// (see comment next to the `histogram` struct definition).
func statsRegisterHistogram(name string, bounds []float64) {
if expvar.Get(name) != nil {
return
}
numBuckets := len(bounds) + 1
expvar.Publish(name, &histogram{
CountPerBucket: make([]int64, numBuckets),