aboutsummaryrefslogtreecommitdiffstats
path: root/library/go/core/metrics/prometheus/counter.go
blob: 1a07063f30a13e911784d3e7edc21ac2726eede9 (plain) (blame)
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
package prometheus

import (
	"github.com/prometheus/client_golang/prometheus"
	"github.com/ydb-platform/ydb/library/go/core/metrics"
)

var _ metrics.Counter = (*Counter)(nil)

// Counter tracks monotonically increasing value.
type Counter struct {
	cnt prometheus.Counter
}

// Inc increments counter by 1.
func (c Counter) Inc() {
	c.cnt.Inc()
}

// Add adds delta to the counter. Delta must be >=0.
func (c Counter) Add(delta int64) {
	c.cnt.Add(float64(delta))
}

var _ metrics.FuncCounter = (*FuncCounter)(nil)

type FuncCounter struct {
	cnt      prometheus.CounterFunc
	function func() int64
}

func (c FuncCounter) Function() func() int64 {
	return c.function
}