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.
31 lines
589 B
31 lines
589 B
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) |
|
}
|
|
|