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/summary.go

33 lines
600 B

package prometheus
import (
"github.com/prometheus/client_golang/prometheus"
1 year ago
"gitea.drugeyes.vip/pharnexbase/kratos/v2/metrics"
)
var _ metrics.Observer = (*summary)(nil)
type summary struct {
sv *prometheus.SummaryVec
lvs []string
}
// NewSummary new a prometheus summary and returns Histogram.
func NewSummary(sv *prometheus.SummaryVec) metrics.Observer {
return &summary{
sv: sv,
}
}
func (s *summary) With(lvs ...string) metrics.Observer {
return &summary{
sv: s.sv,
lvs: lvs,
}
}
func (s *summary) Observe(value float64) {
s.sv.WithLabelValues(s.lvs...).Observe(value)
}