mirror of
https://github.com/openimsdk/open-im-server.git
synced 2026-05-15 22:39:03 +08:00
prome
This commit is contained in:
@@ -25,7 +25,12 @@ var (
|
||||
GrpcRequestSuccessCounter prometheus.Counter
|
||||
GrpcRequestFailedCounter prometheus.Counter
|
||||
|
||||
SendMsgCounter prometheus.Counter
|
||||
SendMsgCounter prometheus.Counter
|
||||
MsgInsertRedisSuccessCounter prometheus.Counter
|
||||
MsgInsertRedisFailedCounter prometheus.Counter
|
||||
|
||||
MsgInsertMongoSuccessCounter prometheus.Counter
|
||||
MsgInsertMongoFailedCounter prometheus.Counter
|
||||
)
|
||||
|
||||
func NewUserLoginCounter() {
|
||||
@@ -34,6 +39,12 @@ func NewUserLoginCounter() {
|
||||
Help: "The number of user login",
|
||||
})
|
||||
}
|
||||
func NewUserRegisterCounter() {
|
||||
UserRegisterCounter = promauto.NewCounter(prometheus.CounterOpts{
|
||||
Name: "user_register",
|
||||
Help: "The number of user register",
|
||||
})
|
||||
}
|
||||
|
||||
func NewUserRegisterCounter() {
|
||||
UserRegisterCounter = promauto.NewCounter(prometheus.CounterOpts{
|
||||
@@ -116,3 +127,31 @@ func NewSendMsgCount() {
|
||||
Help: "The number of send msg",
|
||||
})
|
||||
}
|
||||
|
||||
func NewMsgInsertRedisSuccessCounter() {
|
||||
MsgInsertRedisSuccessCounter = promauto.NewCounter(prometheus.CounterOpts{
|
||||
Name: "msg_insert_redis_success",
|
||||
Help: "The number of successful insert msg to redis",
|
||||
})
|
||||
}
|
||||
|
||||
func NewMsgInsertRedisFailedCounter() {
|
||||
MsgInsertRedisFailedCounter = promauto.NewCounter(prometheus.CounterOpts{
|
||||
Name: "msg_insert_redis_failed",
|
||||
Help: "The number of failed insert msg to redis",
|
||||
})
|
||||
}
|
||||
|
||||
func NewMsgInsertMongoSuccessCounter() {
|
||||
MsgInsertMongoSuccessCounter = promauto.NewCounter(prometheus.CounterOpts{
|
||||
Name: "msg_insert_mongo_success",
|
||||
Help: "The number of successful insert msg to mongo",
|
||||
})
|
||||
}
|
||||
|
||||
func NewMsgInsertMongoFailedCounter() {
|
||||
MsgInsertMongoFailedCounter = promauto.NewCounter(prometheus.CounterOpts{
|
||||
Name: "msg_insert_mongo_failed",
|
||||
Help: "The number of failed insert msg to mongo",
|
||||
})
|
||||
}
|
||||
|
||||
@@ -51,12 +51,17 @@ func PromeTheusMiddleware(c *gin.Context) {
|
||||
|
||||
func PromeInc(counter prometheus.Counter) {
|
||||
if config.Config.Prometheus.Enable {
|
||||
counter.Inc()
|
||||
if counter != nil {
|
||||
counter.Inc()
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
func PromeAdd(counter prometheus.Counter, add int) {
|
||||
if config.Config.Prometheus.Enable {
|
||||
counter.Add(float64(add))
|
||||
if counter != nil {
|
||||
counter.Add(float64(add))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user