3 import "github.com/prometheus/client_golang/prometheus"
5 // Counter is a metrics that can only increment its current count
6 type Counter interface {
7 // Inc adds Sum(vs) to the counter. Sum(vs) must be positive.
9 // If len(vs) == 0, increments the counter by 1.
13 // LabeledCounter is counter that must have labels populated before use.
14 type LabeledCounter interface {
15 WithValues(vs ...string) Counter
18 type labeledCounter struct {
19 pc *prometheus.CounterVec
22 func (lc *labeledCounter) WithValues(vs ...string) Counter {
23 return &counter{pc: lc.pc.WithLabelValues(vs...)}
26 func (lc *labeledCounter) Describe(ch chan<- *prometheus.Desc) {
30 func (lc *labeledCounter) Collect(ch chan<- prometheus.Metric) {
38 func (c *counter) Inc(vs ...float64) {
43 c.pc.Add(sumFloat64(vs...))
46 func (c *counter) Describe(ch chan<- *prometheus.Desc) {
50 func (c *counter) Collect(ch chan<- prometheus.Metric) {