Skip to content
Snippets Groups Projects
Commit b9b0317f authored by Kamil Kisiel's avatar Kamil Kisiel
Browse files

Simplify, remove thresholds

parent 69e8200c
No related branches found
No related tags found
No related merge requests found
......@@ -21,10 +21,10 @@ func init() {
defaultGraphiteAddr = "localhost:2003"
defaultFlushInterval = 10 * time.Second
)
flag.StringVar(&metricsAddr, "l", defaultMetricsAddr, "Address on which to listen for metrics")
flag.StringVar(&consoleAddr, "c", defaultConsoleAddr, "Address on which to listen for console sessions")
flag.StringVar(&graphiteAddr, "g", defaultGraphiteAddr, "Address of the graphite server")
flag.DurationVar(&flushInterval, "f", defaultFlushInterval, "How often to flush metrics to the graphite server")
flag.StringVar(&metricsAddr, "l", defaultMetricsAddr, "address on which to listen for metrics")
flag.StringVar(&consoleAddr, "c", defaultConsoleAddr, "address on which to listen for console sessions")
flag.StringVar(&graphiteAddr, "g", defaultGraphiteAddr, "address of the graphite server")
flag.DurationVar(&flushInterval, "f", defaultFlushInterval, "how often to flush metrics to the graphite server")
}
func main() {
......
......@@ -3,17 +3,10 @@ package statsd
import (
"log"
"sort"
"strconv"
"sync"
"time"
)
var percentThresholds []float64
func init() {
percentThresholds = []float64{90.0}
}
// metricAggregatorStats is a bookkeeping structure for statistics about a MetricAggregator
type metricAggregatorStats struct {
BadLines int
......@@ -78,13 +71,6 @@ func (m *MetricAggregator) flush() (metrics MetricMap) {
metrics["stats.timers."+k+".lower"] = min
metrics["stats.timers."+k+".upper"] = max
metrics["stats.timers."+k+".count"] = float64(count)
for _, threshold := range percentThresholds {
mean, upper := thresholdStats(v, threshold)
thresholdName := strconv.FormatFloat(threshold, 'f', 1, 64)
metrics["stats.timers."+k+"mean_"+thresholdName] = mean
metrics["stats.timers."+k+"upper_"+thresholdName] = upper
}
numStats += 1
}
}
......
......@@ -17,19 +17,3 @@ func average(vals []float64) float64 {
}
return sum / float64(len(vals))
}
// thresholdStats calculates the mean and upper values of a list of values after a applying a minimum threshold
func thresholdStats(vals []float64, threshold float64) (mean, upper float64) {
if count := len(vals); count > 1 {
idx := int(round(((100 - threshold) / 100) * float64(count)))
thresholdCount := count - idx
thresholdValues := vals[:thresholdCount]
mean = average(thresholdValues)
upper = thresholdValues[len(thresholdValues)-1]
} else {
mean = vals[0]
upper = vals[0]
}
return mean, upper
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment