-
Notifications
You must be signed in to change notification settings - Fork 7
/
recorder.go
41 lines (33 loc) · 1.11 KB
/
recorder.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package ingester
import (
"github.com/prometheus/client_golang/prometheus"
)
const (
prefix = "datadog_proxy_ingester"
)
//go:generate mockery --inpackage --testonly --case underscore --name Recorder
type Recorder interface {
measureMetricsParsed(count int)
}
// NewRecorder returns a new Prometheus metrics Recorder.
// It ensures that the ingester metrics are properly registered.
func NewRecorder(reg prometheus.Registerer) Recorder {
r := &prometheusRecorder{
proxyMetricsParsed: prometheus.NewCounterVec(prometheus.CounterOpts{
Namespace: prefix,
Name: "metrics_parsed_total",
Help: "The total number of metrics that have been parsed.",
}, []string{}),
}
reg.MustRegister(r.proxyMetricsParsed)
return r
}
// prometheusRecorder knows the metrics of the ingester and how to measure them for
// Prometheus.
type prometheusRecorder struct {
proxyMetricsParsed *prometheus.CounterVec
}
// measureMetricsParsed measures the total amount of parsed metrics on Prometheus.
func (r prometheusRecorder) measureMetricsParsed(count int) {
r.proxyMetricsParsed.WithLabelValues().Add(float64(count))
}