Observability/metrics update (#1962)

* Removing logging from the NOOP implementatino

* Simplifying the percentiles option

* Simple logging implementation

Co-authored-by: chris <chris@Profanity.local>
This commit is contained in:
Prawn
2020-08-21 20:57:10 +12:00
committed by GitHub
parent 1ae825032c
commit f9f61d29de
7 changed files with 142 additions and 20 deletions

View File

@@ -19,13 +19,22 @@ type metricFamily struct {
// newMetricFamily returns a new metricFamily (useful in case we want to change the structure later):
func (r *Reporter) newMetricFamily() metricFamily {
// Take quantile thresholds from our pre-defined list:
timingObjectives := make(map[float64]float64)
for _, percentile := range r.options.Percentiles {
if quantileThreshold, ok := quantileThresholds[percentile]; ok {
timingObjectives[percentile] = quantileThreshold
}
}
return metricFamily{
counters: make(map[string]*prometheus.CounterVec),
gauges: make(map[string]*prometheus.GaugeVec),
timings: make(map[string]*prometheus.SummaryVec),
defaultLabels: r.convertTags(r.options.DefaultTags),
prometheusRegistry: r.prometheusRegistry,
timingObjectives: r.options.TimingObjectives,
timingObjectives: timingObjectives,
}
}

View File

@@ -10,6 +10,12 @@ import (
"github.com/prometheus/client_golang/prometheus/promhttp"
)
var (
// quantileThresholds maps quantiles / percentiles to error thresholds (required by the Prometheus client).
// Must be from our pre-defined set [0.0, 0.5, 0.75, 0.90, 0.95, 0.98, 0.99, 1]:
quantileThresholds = map[float64]float64{0.0: 0, 0.5: 0.05, 0.75: 0.04, 0.90: 0.03, 0.95: 0.02, 0.98: 0.001, 1: 0}
)
// Reporter is an implementation of metrics.Reporter:
type Reporter struct {
options metrics.Options