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.
 
 
 

35 lines
643 B

package prometheus
import (
"github.com/go-kratos/kratos/v2/metrics"
"github.com/prometheus/client_golang/prometheus"
)
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)
}