mirror of https://github.com/tidwall/tile38.git
fix #717 not returned metrics
expired_keys never incremented additional metrics not returned from metrics endpoint
This commit is contained in:
parent
946031456e
commit
c78c8b4287
|
@ -32,6 +32,7 @@ func (s *Server) backgroundExpireObjects(now time.Time) {
|
|||
if nano < o.Expires() {
|
||||
return false
|
||||
}
|
||||
s.statsExpired.Add(1)
|
||||
msgs = append(msgs, &Message{Args: []string{"del", key, o.ID()}})
|
||||
return true
|
||||
})
|
||||
|
|
|
@ -92,13 +92,7 @@ func (s *Server) Collect(ch chan<- prometheus.Metric) {
|
|||
s.extStats(m)
|
||||
|
||||
for metric, descr := range metricDescriptions {
|
||||
val, ok := m[metric].(float64)
|
||||
if !ok {
|
||||
val2, ok2 := m[metric].(int)
|
||||
if ok2 {
|
||||
val, ok = float64(val2), true
|
||||
}
|
||||
}
|
||||
val, ok := toFloat(m[metric])
|
||||
if ok {
|
||||
ch <- prometheus.MustNewConstMetric(descr, prometheus.GaugeValue, val)
|
||||
}
|
||||
|
@ -155,3 +149,31 @@ func (s *Server) Collect(ch chan<- prometheus.Metric) {
|
|||
return true
|
||||
})
|
||||
}
|
||||
|
||||
func toFloat(val interface{}) (float64, bool) {
|
||||
switch v := val.(type) {
|
||||
case float64:
|
||||
return v, true
|
||||
case int64:
|
||||
return float64(v), true
|
||||
case uint64:
|
||||
return float64(v), true
|
||||
case float32:
|
||||
return float64(v), true
|
||||
case int:
|
||||
return float64(v), true
|
||||
case int32:
|
||||
return float64(v), true
|
||||
case uint32:
|
||||
return float64(v), true
|
||||
case int16:
|
||||
return float64(v), true
|
||||
case uint16:
|
||||
return float64(v), true
|
||||
case int8:
|
||||
return float64(v), true
|
||||
case uint8:
|
||||
return float64(v), true
|
||||
}
|
||||
return 0, false
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue