You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
kratos/contrib/metrics/prometheus/counter.go

36 lines
654 B

package prometheus
import (
"github.com/prometheus/client_golang/prometheus"
"gitea.drugeyes.vip/pharnexbase/kratos/v2/metrics"
)
var _ metrics.Counter = (*counter)(nil)
type counter struct {
cv *prometheus.CounterVec
lvs []string
}
// NewCounter new a prometheus counter and returns Counter.
func NewCounter(cv *prometheus.CounterVec) metrics.Counter {
return &counter{
cv: cv,
}
}
func (c *counter) With(lvs ...string) metrics.Counter {
return &counter{
cv: c.cv,
lvs: lvs,
}
}
func (c *counter) Inc() {
c.cv.WithLabelValues(c.lvs...).Inc()
}
func (c *counter) Add(delta float64) {
c.cv.WithLabelValues(c.lvs...).Add(delta)
}