mirror of
https://github.com/openimsdk/open-im-server.git
synced 2026-05-05 01:25:58 +08:00
prome
This commit is contained in:
@@ -6,6 +6,7 @@ import (
|
||||
"Open_IM/pkg/common/db"
|
||||
"Open_IM/pkg/common/kafka"
|
||||
"Open_IM/pkg/common/log"
|
||||
promePkg "Open_IM/pkg/common/prometheus"
|
||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||
"Open_IM/pkg/proto/msg"
|
||||
"Open_IM/pkg/utils"
|
||||
@@ -13,16 +14,9 @@ import (
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
"github.com/prometheus/client_golang/prometheus/promauto"
|
||||
"google.golang.org/grpc"
|
||||
)
|
||||
|
||||
var (
|
||||
sendMsgSuccessCounter prometheus.Counter
|
||||
sendMsgFailedCounter prometheus.Counter
|
||||
)
|
||||
|
||||
type rpcChat struct {
|
||||
rpcPort int
|
||||
rpcRegisterName string
|
||||
@@ -55,14 +49,7 @@ func NewRpcChatServer(port int) *rpcChat {
|
||||
}
|
||||
|
||||
func (rpc *rpcChat) initPrometheus() {
|
||||
sendMsgSuccessCounter = promauto.NewCounter(prometheus.CounterOpts{
|
||||
Name: "send_msg_success",
|
||||
Help: "The number of send msg success",
|
||||
})
|
||||
sendMsgFailedCounter = promauto.NewCounter(prometheus.CounterOpts{
|
||||
Name: "send_msg_failed",
|
||||
Help: "The number of send msg failed",
|
||||
})
|
||||
promePkg.NewSendMsgCount()
|
||||
}
|
||||
|
||||
func (rpc *rpcChat) Run() {
|
||||
@@ -80,7 +67,11 @@ func (rpc *rpcChat) Run() {
|
||||
}
|
||||
log.Info("", "listen network success, address ", address)
|
||||
|
||||
srv := grpc.NewServer()
|
||||
var grpcOpts []grpc.ServerOption
|
||||
if config.Config.Prometheus.Enable {
|
||||
grpcOpts = append(grpcOpts, promePkg.UnaryServerInterceptorProme)
|
||||
}
|
||||
srv := grpc.NewServer(grpcOpts...)
|
||||
defer srv.GracefulStop()
|
||||
|
||||
rpcRegisterIP := config.Config.RpcRegisterIP
|
||||
|
||||
Reference in New Issue
Block a user