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.

32 lines
589 B

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