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:
@@ -3,6 +3,8 @@ package metric
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/prometheus"
|
||||
|
||||
"github.com/prometheus/client_golang/prometheus/testutil"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
@@ -21,6 +23,7 @@ func TestNewCounterVec(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestCounterIncr(t *testing.T) {
|
||||
startAgent()
|
||||
counterVec := NewCounterVec(&CounterVecOpts{
|
||||
Namespace: "http_client",
|
||||
Subsystem: "call",
|
||||
@@ -37,6 +40,7 @@ func TestCounterIncr(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestCounterAdd(t *testing.T) {
|
||||
startAgent()
|
||||
counterVec := NewCounterVec(&CounterVecOpts{
|
||||
Namespace: "rpc_server",
|
||||
Subsystem: "requests",
|
||||
@@ -51,3 +55,11 @@ func TestCounterAdd(t *testing.T) {
|
||||
r := testutil.ToFloat64(cv.counter)
|
||||
assert.Equal(t, float64(33), r)
|
||||
}
|
||||
|
||||
func startAgent() {
|
||||
prometheus.StartAgent(prometheus.Config{
|
||||
Host: "127.0.0.1",
|
||||
Port: 9101,
|
||||
Path: "/metrics",
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user