feat: add metrics (#3624)
This commit is contained in:
@@ -3,6 +3,7 @@ package redis
|
||||
import (
|
||||
"crypto/tls"
|
||||
"io"
|
||||
"runtime"
|
||||
"strings"
|
||||
|
||||
red "github.com/go-redis/redis/v8"
|
||||
@@ -11,7 +12,11 @@ import (
|
||||
|
||||
const addrSep = ","
|
||||
|
||||
var clusterManager = syncx.NewResourceManager()
|
||||
var (
|
||||
clusterManager = syncx.NewResourceManager()
|
||||
// clusterPoolSize is default pool size for cluster type of redis.
|
||||
clusterPoolSize = 5 * runtime.GOMAXPROCS(0)
|
||||
)
|
||||
|
||||
func getCluster(r *Redis) (*red.ClusterClient, error) {
|
||||
val, err := clusterManager.GetResource(r.Addr, func() (io.Closer, error) {
|
||||
@@ -33,6 +38,15 @@ func getCluster(r *Redis) (*red.ClusterClient, error) {
|
||||
store.AddHook(hook)
|
||||
}
|
||||
|
||||
connCollector.registerClient(&statGetter{
|
||||
clientType: ClusterType,
|
||||
key: r.Addr,
|
||||
poolSize: clusterPoolSize,
|
||||
poolStats: func() *red.PoolStats {
|
||||
return store.PoolStats()
|
||||
},
|
||||
})
|
||||
|
||||
return store, nil
|
||||
})
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user