mirror of
https://github.com/jhillyerd/inbucket.git
synced 2026-01-10 13:15:56 +00:00
Metrics improvements
- Label graphs by their duration, not update period - Extend to 60 units so they are either 10 minutes or an hour of data - Improvements to retention information - Change javascript calculations, fixes #9 (I hope)
This commit is contained in:
@@ -104,11 +104,12 @@ func metricsTicker(t *time.Ticker) {
|
||||
}
|
||||
}
|
||||
|
||||
// pushMetric adds the metric to the end of the list and returns a comma
|
||||
// separated string of the previous 50 entries
|
||||
// pushMetric adds the metric to the end of the list and returns a comma separated string of the
|
||||
// previous 61 entries. We return 61 instead of 60 (an hour) because the chart on the client
|
||||
// tracks deltas between these values - there is nothing to compare the first value against.
|
||||
func pushMetric(history *list.List, ev expvar.Var) string {
|
||||
history.PushBack(ev.String())
|
||||
if history.Len() > 50 {
|
||||
if history.Len() > 61 {
|
||||
history.Remove(history.Front())
|
||||
}
|
||||
return JoinStringList(history)
|
||||
|
||||
@@ -13,6 +13,7 @@ var retentionScanCompleted time.Time
|
||||
var retentionScanCompletedMu sync.RWMutex
|
||||
|
||||
var expRetentionDeletesTotal = new(expvar.Int)
|
||||
var expRetentionPeriod = new(expvar.Int)
|
||||
|
||||
// History of certain stats
|
||||
var retentionDeletesHist = list.New()
|
||||
@@ -22,6 +23,7 @@ var expRetentionDeletesHist = new(expvar.String)
|
||||
|
||||
func StartRetentionScanner(ds DataStore) {
|
||||
cfg := config.GetDataStoreConfig()
|
||||
expRetentionPeriod.Set(int64(cfg.RetentionMinutes * 60))
|
||||
if cfg.RetentionMinutes > 0 {
|
||||
// Retention scanning enabled
|
||||
log.Info("Retention configured for %v minutes", cfg.RetentionMinutes)
|
||||
@@ -109,4 +111,5 @@ func init() {
|
||||
rm.Set("SecondsSinceScanCompleted", expvar.Func(secondsSinceRetentionScanCompleted))
|
||||
rm.Set("DeletesHist", expRetentionDeletesHist)
|
||||
rm.Set("DeletesTotal", expRetentionDeletesTotal)
|
||||
rm.Set("Period", expRetentionPeriod)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user