From 313cf858f065868991e8ae495453fcb016ddf629 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Wed, 18 May 2022 11:52:15 +0800 Subject: [PATCH] Statistics --- internal/msg_gateway/gate/init.go | 2 ++ internal/msg_gateway/gate/logic.go | 2 ++ pkg/common/constant/constant.go | 2 +- 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/internal/msg_gateway/gate/init.go b/internal/msg_gateway/gate/init.go index 5cf682b84..60c97f1de 100644 --- a/internal/msg_gateway/gate/init.go +++ b/internal/msg_gateway/gate/init.go @@ -19,6 +19,8 @@ var ( sendMsgFailedCount uint64 sendMsgSuccessCount uint64 userCount uint64 + + sendMsgAllCountLock sync.RWMutex ) func Init(rpcPort, wsPort int) { diff --git a/internal/msg_gateway/gate/logic.go b/internal/msg_gateway/gate/logic.go index 51955f0fe..5644f1cb3 100644 --- a/internal/msg_gateway/gate/logic.go +++ b/internal/msg_gateway/gate/logic.go @@ -143,7 +143,9 @@ func (ws *WServer) pullMsgBySeqListResp(conn *UserConn, m *Req, pb *sdk_ws.PullM } func (ws *WServer) sendMsgReq(conn *UserConn, m *Req) { + sendMsgAllCountLock.Lock() sendMsgAllCount++ + sendMsgAllCountLock.Unlock() log.NewInfo(m.OperationID, "Ws call success to sendMsgReq start", m.MsgIncr, m.ReqIdentifier, m.SendID, m.Data) nReply := new(pbChat.SendMsgResp) isPass, errCode, errMsg, pData := ws.argsValidate(m, constant.WSSendMsg) diff --git a/pkg/common/constant/constant.go b/pkg/common/constant/constant.go index 33e350003..032108ee9 100644 --- a/pkg/common/constant/constant.go +++ b/pkg/common/constant/constant.go @@ -272,4 +272,4 @@ const BigVersion = "v3" const LogFileName = "OpenIM.log" -const StatisticsTimeInterval = 300 +const StatisticsTimeInterval = 60