Fixup of previous commit.

This commit is contained in:
Eugene Bujak
2018-10-15 19:34:31 +03:00
parent 1ed9faa0c2
commit f0823f1195
2 changed files with 15 additions and 3 deletions

View File

@@ -228,7 +228,8 @@ func (h *histogram) Collect(ch chan<- prometheus.Metric) {
// stats
// -----
func handleStats(w http.ResponseWriter, r *http.Request) {
histrical := generateMapFromStats(&statistics.PerHour, 0, 24)
const numHours = 24
histrical := generateMapFromStats(&statistics.PerHour, 0, numHours)
// sum them up
summed := map[string]interface{}{}
for key, values := range histrical {
@@ -245,7 +246,7 @@ func handleStats(w http.ResponseWriter, r *http.Request) {
// don't forget to divide by number of elements in returned slice
if val, ok := summed["avg_processing_time"]; ok {
if flval, flok := val.(float64); flok {
flval /= float64(len(histrical))
flval /= numHours
summed["avg_processing_time"] = flval
}
}