This commit is contained in:
wangchuxiao
2022-09-15 01:23:57 +08:00
8 changed files with 178 additions and 153 deletions
+40 -1
View File
@@ -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",
})
}
+7 -2
View File
@@ -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))
}
}
}