feat: mysql and redis metric support (#2355)

* feat: mysql and redis metric support

* feat: mysql and redis metric support

* feat: mysql and redis metric support

Co-authored-by: dawn.zhou <dawn.zhou@yijinin.com>
This commit is contained in:
dawn_zhou
2022-09-17 19:35:30 +08:00
committed by GitHub
parent b8664be2bb
commit ae7f1aabdd
15 changed files with 164 additions and 23 deletions

View File

@@ -1,8 +1,10 @@
package metric
import (
prom "github.com/prometheus/client_golang/prometheus"
"github.com/zeromicro/go-zero/core/proc"
"github.com/zeromicro/go-zero/core/prometheus"
prom "github.com/prometheus/client_golang/prometheus"
)
type (
@@ -53,6 +55,10 @@ func NewHistogramVec(cfg *HistogramVecOpts) HistogramVec {
}
func (hv *promHistogramVec) Observe(v int64, labels ...string) {
if !prometheus.Enabled() {
return
}
hv.histogram.WithLabelValues(labels...).Observe(float64(v))
}