You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
427 lines
11 KiB
427 lines
11 KiB
2 years ago
|
package prome
|
||
2 years ago
|
|
||
|
import (
|
||
|
"github.com/prometheus/client_golang/prometheus"
|
||
|
"github.com/prometheus/client_golang/prometheus/promauto"
|
||
|
)
|
||
|
|
||
|
var (
|
||
2 years ago
|
//auth rpc
|
||
2 years ago
|
UserLoginCounter prometheus.Counter
|
||
|
UserRegisterCounter prometheus.Counter
|
||
2 years ago
|
|
||
2 years ago
|
//seg
|
||
2 years ago
|
SeqGetSuccessCounter prometheus.Counter
|
||
|
SeqGetFailedCounter prometheus.Counter
|
||
|
SeqSetSuccessCounter prometheus.Counter
|
||
|
SeqSetFailedCounter prometheus.Counter
|
||
2 years ago
|
|
||
2 years ago
|
//msg-db
|
||
|
MsgInsertRedisSuccessCounter prometheus.Counter
|
||
|
MsgInsertRedisFailedCounter prometheus.Counter
|
||
|
MsgInsertMongoSuccessCounter prometheus.Counter
|
||
|
MsgInsertMongoFailedCounter prometheus.Counter
|
||
|
MsgPullFromRedisSuccessCounter prometheus.Counter
|
||
|
MsgPullFromRedisFailedCounter prometheus.Counter
|
||
|
MsgPullFromMongoSuccessCounter prometheus.Counter
|
||
|
MsgPullFromMongoFailedCounter prometheus.Counter
|
||
2 years ago
|
|
||
2 years ago
|
//msg-ws
|
||
|
MsgRecvTotalCounter prometheus.Counter
|
||
|
GetNewestSeqTotalCounter prometheus.Counter
|
||
|
PullMsgBySeqListTotalCounter prometheus.Counter
|
||
|
|
||
|
SingleChatMsgRecvSuccessCounter prometheus.Counter
|
||
|
GroupChatMsgRecvSuccessCounter prometheus.Counter
|
||
|
WorkSuperGroupChatMsgRecvSuccessCounter prometheus.Counter
|
||
2 years ago
|
OnlineUserGauge prometheus.Gauge
|
||
2 years ago
|
|
||
|
//msg-msg
|
||
|
SingleChatMsgProcessSuccessCounter prometheus.Counter
|
||
|
SingleChatMsgProcessFailedCounter prometheus.Counter
|
||
|
GroupChatMsgProcessSuccessCounter prometheus.Counter
|
||
|
GroupChatMsgProcessFailedCounter prometheus.Counter
|
||
|
WorkSuperGroupChatMsgProcessSuccessCounter prometheus.Counter
|
||
|
WorkSuperGroupChatMsgProcessFailedCounter prometheus.Counter
|
||
|
|
||
|
//msg-push
|
||
|
MsgOnlinePushSuccessCounter prometheus.Counter
|
||
|
MsgOfflinePushSuccessCounter prometheus.Counter
|
||
|
MsgOfflinePushFailedCounter prometheus.Counter
|
||
2 years ago
|
// api
|
||
|
ApiRequestCounter prometheus.Counter
|
||
|
ApiRequestSuccessCounter prometheus.Counter
|
||
|
ApiRequestFailedCounter prometheus.Counter
|
||
|
|
||
|
// grpc
|
||
|
GrpcRequestCounter prometheus.Counter
|
||
|
GrpcRequestSuccessCounter prometheus.Counter
|
||
|
GrpcRequestFailedCounter prometheus.Counter
|
||
|
|
||
2 years ago
|
SendMsgCounter prometheus.Counter
|
||
2 years ago
|
)
|
||
|
|
||
|
func NewUserLoginCounter() {
|
||
2 years ago
|
if UserLoginCounter != nil {
|
||
|
return
|
||
|
}
|
||
2 years ago
|
UserLoginCounter = promauto.NewCounter(prometheus.CounterOpts{
|
||
|
Name: "user_login",
|
||
|
Help: "The number of user login",
|
||
|
})
|
||
|
}
|
||
2 years ago
|
func NewUserRegisterCounter() {
|
||
2 years ago
|
if UserRegisterCounter != nil {
|
||
|
return
|
||
|
}
|
||
2 years ago
|
UserRegisterCounter = promauto.NewCounter(prometheus.CounterOpts{
|
||
|
Name: "user_register",
|
||
|
Help: "The number of user register",
|
||
|
})
|
||
|
}
|
||
2 years ago
|
|
||
2 years ago
|
func NewSeqGetSuccessCounter() {
|
||
2 years ago
|
if SeqGetSuccessCounter != nil {
|
||
|
return
|
||
|
}
|
||
2 years ago
|
SeqGetSuccessCounter = promauto.NewCounter(prometheus.CounterOpts{
|
||
|
Name: "seq_get_success",
|
||
|
Help: "The number of successful get seq",
|
||
|
})
|
||
|
}
|
||
|
func NewSeqGetFailedCounter() {
|
||
2 years ago
|
if SeqGetFailedCounter != nil {
|
||
|
return
|
||
|
}
|
||
2 years ago
|
SeqGetFailedCounter = promauto.NewCounter(prometheus.CounterOpts{
|
||
|
Name: "seq_get_failed",
|
||
|
Help: "The number of failed get seq",
|
||
|
})
|
||
|
}
|
||
|
|
||
|
func NewSeqSetSuccessCounter() {
|
||
2 years ago
|
if SeqSetSuccessCounter != nil {
|
||
|
return
|
||
|
}
|
||
2 years ago
|
SeqSetSuccessCounter = promauto.NewCounter(prometheus.CounterOpts{
|
||
|
Name: "seq_set_success",
|
||
|
Help: "The number of successful set seq",
|
||
|
})
|
||
|
}
|
||
|
func NewSeqSetFailedCounter() {
|
||
2 years ago
|
if SeqSetFailedCounter != nil {
|
||
|
return
|
||
|
}
|
||
2 years ago
|
SeqSetFailedCounter = promauto.NewCounter(prometheus.CounterOpts{
|
||
|
Name: "seq_set_failed",
|
||
|
Help: "The number of failed set seq",
|
||
2 years ago
|
})
|
||
|
}
|
||
2 years ago
|
|
||
2 years ago
|
func NewApiRequestCounter() {
|
||
2 years ago
|
if ApiRequestCounter != nil {
|
||
|
return
|
||
|
}
|
||
2 years ago
|
ApiRequestCounter = promauto.NewCounter(prometheus.CounterOpts{
|
||
|
Name: "api_request",
|
||
|
Help: "The number of api request",
|
||
|
})
|
||
|
}
|
||
|
|
||
|
func NewApiRequestSuccessCounter() {
|
||
2 years ago
|
if ApiRequestSuccessCounter != nil {
|
||
|
return
|
||
|
}
|
||
2 years ago
|
ApiRequestSuccessCounter = promauto.NewCounter(prometheus.CounterOpts{
|
||
|
Name: "api_request_success",
|
||
|
Help: "The number of api request success",
|
||
|
})
|
||
|
}
|
||
|
|
||
|
func NewApiRequestFailedCounter() {
|
||
2 years ago
|
if ApiRequestFailedCounter != nil {
|
||
|
return
|
||
|
}
|
||
2 years ago
|
ApiRequestFailedCounter = promauto.NewCounter(prometheus.CounterOpts{
|
||
|
Name: "api_request_failed",
|
||
|
Help: "The number of api request failed",
|
||
|
})
|
||
|
}
|
||
|
|
||
|
func NewGrpcRequestCounter() {
|
||
2 years ago
|
if GrpcRequestCounter != nil {
|
||
|
return
|
||
|
}
|
||
2 years ago
|
GrpcRequestCounter = promauto.NewCounter(prometheus.CounterOpts{
|
||
|
Name: "grpc_request",
|
||
|
Help: "The number of api request",
|
||
|
})
|
||
|
}
|
||
|
|
||
|
func NewGrpcRequestSuccessCounter() {
|
||
2 years ago
|
if GrpcRequestSuccessCounter != nil {
|
||
|
return
|
||
|
}
|
||
2 years ago
|
GrpcRequestSuccessCounter = promauto.NewCounter(prometheus.CounterOpts{
|
||
|
Name: "grpc_request_success",
|
||
|
Help: "The number of grpc request success",
|
||
|
})
|
||
|
}
|
||
|
|
||
|
func NewGrpcRequestFailedCounter() {
|
||
2 years ago
|
if GrpcRequestFailedCounter != nil {
|
||
|
return
|
||
|
}
|
||
2 years ago
|
GrpcRequestFailedCounter = promauto.NewCounter(prometheus.CounterOpts{
|
||
|
Name: "grpc_request_failed",
|
||
|
Help: "The number of grpc request failed",
|
||
|
})
|
||
|
}
|
||
|
|
||
|
func NewSendMsgCount() {
|
||
2 years ago
|
if SendMsgCounter != nil {
|
||
|
return
|
||
|
}
|
||
2 years ago
|
SendMsgCounter = promauto.NewCounter(prometheus.CounterOpts{
|
||
|
Name: "send_msg",
|
||
|
Help: "The number of send msg",
|
||
|
})
|
||
|
}
|
||
2 years ago
|
|
||
2 years ago
|
func NewMsgInsertRedisSuccessCounter() {
|
||
2 years ago
|
if MsgInsertRedisSuccessCounter != nil {
|
||
|
return
|
||
|
}
|
||
2 years ago
|
MsgInsertRedisSuccessCounter = promauto.NewCounter(prometheus.CounterOpts{
|
||
|
Name: "msg_insert_redis_success",
|
||
|
Help: "The number of successful insert msg to redis",
|
||
|
})
|
||
|
}
|
||
|
|
||
|
func NewMsgInsertRedisFailedCounter() {
|
||
2 years ago
|
if MsgInsertRedisFailedCounter != nil {
|
||
|
return
|
||
|
}
|
||
2 years ago
|
MsgInsertRedisFailedCounter = promauto.NewCounter(prometheus.CounterOpts{
|
||
|
Name: "msg_insert_redis_failed",
|
||
|
Help: "The number of failed insert msg to redis",
|
||
|
})
|
||
|
}
|
||
2 years ago
|
|
||
|
func NewMsgInsertMongoSuccessCounter() {
|
||
2 years ago
|
if MsgInsertMongoSuccessCounter != nil {
|
||
|
return
|
||
|
}
|
||
2 years ago
|
MsgInsertMongoSuccessCounter = promauto.NewCounter(prometheus.CounterOpts{
|
||
|
Name: "msg_insert_mongo_success",
|
||
|
Help: "The number of successful insert msg to mongo",
|
||
|
})
|
||
|
}
|
||
|
|
||
|
func NewMsgInsertMongoFailedCounter() {
|
||
2 years ago
|
if MsgInsertMongoFailedCounter != nil {
|
||
|
return
|
||
|
}
|
||
2 years ago
|
MsgInsertMongoFailedCounter = promauto.NewCounter(prometheus.CounterOpts{
|
||
|
Name: "msg_insert_mongo_failed",
|
||
|
Help: "The number of failed insert msg to mongo",
|
||
|
})
|
||
|
}
|
||
2 years ago
|
|
||
|
func NewMsgPullFromRedisSuccessCounter() {
|
||
2 years ago
|
if MsgPullFromRedisSuccessCounter != nil {
|
||
|
return
|
||
|
}
|
||
2 years ago
|
MsgPullFromRedisSuccessCounter = promauto.NewCounter(prometheus.CounterOpts{
|
||
|
Name: "msg_pull_from_redis_success",
|
||
|
Help: "The number of successful pull msg from redis",
|
||
|
})
|
||
|
}
|
||
|
|
||
|
func NewMsgPullFromRedisFailedCounter() {
|
||
2 years ago
|
if MsgPullFromRedisFailedCounter != nil {
|
||
|
return
|
||
|
}
|
||
2 years ago
|
MsgPullFromRedisFailedCounter = promauto.NewCounter(prometheus.CounterOpts{
|
||
|
Name: "msg_pull_from_redis_failed",
|
||
|
Help: "The number of failed pull msg from redis",
|
||
|
})
|
||
|
}
|
||
|
|
||
|
func NewMsgPullFromMongoSuccessCounter() {
|
||
2 years ago
|
if MsgPullFromMongoSuccessCounter != nil {
|
||
|
return
|
||
|
}
|
||
2 years ago
|
MsgPullFromMongoSuccessCounter = promauto.NewCounter(prometheus.CounterOpts{
|
||
2 years ago
|
Name: "msg_pull_from_mongo_success",
|
||
2 years ago
|
Help: "The number of successful pull msg from mongo",
|
||
|
})
|
||
|
}
|
||
|
|
||
|
func NewMsgPullFromMongoFailedCounter() {
|
||
2 years ago
|
if MsgPullFromMongoFailedCounter != nil {
|
||
|
return
|
||
|
}
|
||
2 years ago
|
MsgPullFromMongoFailedCounter = promauto.NewCounter(prometheus.CounterOpts{
|
||
|
Name: "msg_pull_from_mongo_failed",
|
||
|
Help: "The number of failed pull msg from mongo",
|
||
|
})
|
||
|
}
|
||
|
|
||
|
func NewMsgRecvTotalCounter() {
|
||
2 years ago
|
if MsgRecvTotalCounter != nil {
|
||
|
return
|
||
|
}
|
||
2 years ago
|
MsgRecvTotalCounter = promauto.NewCounter(prometheus.CounterOpts{
|
||
|
Name: "msg_recv_total",
|
||
|
Help: "The number of msg received",
|
||
|
})
|
||
|
}
|
||
|
|
||
|
func NewGetNewestSeqTotalCounter() {
|
||
2 years ago
|
if GetNewestSeqTotalCounter != nil {
|
||
|
return
|
||
|
}
|
||
2 years ago
|
GetNewestSeqTotalCounter = promauto.NewCounter(prometheus.CounterOpts{
|
||
|
Name: "get_newest_seq_total",
|
||
|
Help: "the number of get newest seq",
|
||
|
})
|
||
|
}
|
||
|
func NewPullMsgBySeqListTotalCounter() {
|
||
2 years ago
|
if PullMsgBySeqListTotalCounter != nil {
|
||
|
return
|
||
|
}
|
||
2 years ago
|
PullMsgBySeqListTotalCounter = promauto.NewCounter(prometheus.CounterOpts{
|
||
|
Name: "pull_msg_by_seq_list_total",
|
||
|
Help: "The number of pull msg by seq list",
|
||
|
})
|
||
|
}
|
||
|
|
||
|
func NewSingleChatMsgRecvSuccessCounter() {
|
||
2 years ago
|
if SingleChatMsgRecvSuccessCounter != nil {
|
||
|
return
|
||
|
}
|
||
2 years ago
|
SingleChatMsgRecvSuccessCounter = promauto.NewCounter(prometheus.CounterOpts{
|
||
|
Name: "single_chat_msg_recv_success",
|
||
|
Help: "The number of single chat msg successful received ",
|
||
|
})
|
||
|
}
|
||
|
|
||
|
func NewGroupChatMsgRecvSuccessCounter() {
|
||
2 years ago
|
if GroupChatMsgRecvSuccessCounter != nil {
|
||
|
return
|
||
|
}
|
||
2 years ago
|
GroupChatMsgRecvSuccessCounter = promauto.NewCounter(prometheus.CounterOpts{
|
||
|
Name: "group_chat_msg_recv_success",
|
||
|
Help: "The number of group chat msg successful received",
|
||
|
})
|
||
|
}
|
||
|
|
||
|
func NewWorkSuperGroupChatMsgRecvSuccessCounter() {
|
||
2 years ago
|
if WorkSuperGroupChatMsgRecvSuccessCounter != nil {
|
||
|
return
|
||
|
}
|
||
2 years ago
|
WorkSuperGroupChatMsgRecvSuccessCounter = promauto.NewCounter(prometheus.CounterOpts{
|
||
|
Name: "work_super_group_chat_msg_recv_success",
|
||
|
Help: "The number of work/super group chat msg successful received",
|
||
|
})
|
||
|
}
|
||
|
|
||
2 years ago
|
func NewOnlineUserGauges() {
|
||
|
if OnlineUserGauge != nil {
|
||
|
return
|
||
|
}
|
||
|
OnlineUserGauge = promauto.NewGauge(prometheus.GaugeOpts{
|
||
|
Name: "online_user_num",
|
||
|
Help: "The number of online user num",
|
||
|
})
|
||
|
}
|
||
|
|
||
2 years ago
|
func NewSingleChatMsgProcessSuccessCounter() {
|
||
2 years ago
|
if SingleChatMsgProcessSuccessCounter != nil {
|
||
|
return
|
||
|
}
|
||
2 years ago
|
SingleChatMsgProcessSuccessCounter = promauto.NewCounter(prometheus.CounterOpts{
|
||
|
Name: "single_chat_msg_process_success",
|
||
|
Help: "The number of single chat msg successful processed",
|
||
|
})
|
||
|
}
|
||
|
|
||
|
func NewSingleChatMsgProcessFailedCounter() {
|
||
2 years ago
|
if SingleChatMsgProcessFailedCounter != nil {
|
||
|
return
|
||
|
}
|
||
2 years ago
|
SingleChatMsgProcessFailedCounter = promauto.NewCounter(prometheus.CounterOpts{
|
||
|
Name: "single_chat_msg_process_failed",
|
||
|
Help: "The number of single chat msg failed processed",
|
||
|
})
|
||
|
}
|
||
|
|
||
|
func NewGroupChatMsgProcessSuccessCounter() {
|
||
2 years ago
|
if GroupChatMsgProcessSuccessCounter != nil {
|
||
|
return
|
||
|
}
|
||
2 years ago
|
GroupChatMsgProcessSuccessCounter = promauto.NewCounter(prometheus.CounterOpts{
|
||
|
Name: "group_chat_msg_process_success",
|
||
|
Help: "The number of group chat msg successful processed",
|
||
|
})
|
||
|
}
|
||
|
|
||
|
func NewGroupChatMsgProcessFailedCounter() {
|
||
2 years ago
|
if GroupChatMsgProcessFailedCounter != nil {
|
||
|
return
|
||
|
}
|
||
2 years ago
|
GroupChatMsgProcessFailedCounter = promauto.NewCounter(prometheus.CounterOpts{
|
||
|
Name: "group_chat_msg_process_failed",
|
||
|
Help: "The number of group chat msg failed processed",
|
||
|
})
|
||
|
}
|
||
|
|
||
|
func NewWorkSuperGroupChatMsgProcessSuccessCounter() {
|
||
2 years ago
|
if WorkSuperGroupChatMsgProcessSuccessCounter != nil {
|
||
|
return
|
||
|
}
|
||
2 years ago
|
WorkSuperGroupChatMsgProcessSuccessCounter = promauto.NewCounter(prometheus.CounterOpts{
|
||
|
Name: "work_super_group_chat_msg_process_success",
|
||
|
Help: "The number of work/super group chat msg successful processed",
|
||
|
})
|
||
|
}
|
||
|
func NewWorkSuperGroupChatMsgProcessFailedCounter() {
|
||
2 years ago
|
if WorkSuperGroupChatMsgProcessFailedCounter != nil {
|
||
|
return
|
||
|
}
|
||
2 years ago
|
WorkSuperGroupChatMsgProcessFailedCounter = promauto.NewCounter(prometheus.CounterOpts{
|
||
|
Name: "work_super_group_chat_msg_process_failed",
|
||
|
Help: "The number of work/super group chat msg failed processed",
|
||
|
})
|
||
|
}
|
||
|
|
||
|
func NewMsgOnlinePushSuccessCounter() {
|
||
2 years ago
|
if MsgOnlinePushSuccessCounter != nil {
|
||
|
return
|
||
|
}
|
||
2 years ago
|
MsgOnlinePushSuccessCounter = promauto.NewCounter(prometheus.CounterOpts{
|
||
|
Name: "msg_online_push_success",
|
||
|
Help: "The number of msg successful online pushed",
|
||
|
})
|
||
|
}
|
||
|
|
||
|
func NewMsgOfflinePushSuccessCounter() {
|
||
2 years ago
|
if MsgOfflinePushSuccessCounter != nil {
|
||
|
return
|
||
|
}
|
||
2 years ago
|
MsgOfflinePushSuccessCounter = promauto.NewCounter(prometheus.CounterOpts{
|
||
|
Name: "msg_offline_push_success",
|
||
|
Help: "The number of msg successful offline pushed",
|
||
|
})
|
||
|
}
|
||
|
func NewMsgOfflinePushFailedCounter() {
|
||
2 years ago
|
if MsgOfflinePushFailedCounter != nil {
|
||
|
return
|
||
|
}
|
||
2 years ago
|
MsgOfflinePushFailedCounter = promauto.NewCounter(prometheus.CounterOpts{
|
||
|
Name: "msg_offline_push_failed",
|
||
|
Help: "The number of msg failed offline pushed",
|
||
|
})
|
||
|
}
|