1
0
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:
James Hillyerd
2012-11-14 17:22:25 -08:00
parent 2ba9eaa779
commit afe14da506
5 changed files with 48 additions and 21 deletions

View File

@@ -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)

View File

@@ -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)
}