prometheus

This commit is contained in:
wangchuxiao
2022-09-15 17:50:45 +08:00
parent 78ce5c3f69
commit 1cfa55817a
4 changed files with 31 additions and 0 deletions
+11
View File
@@ -34,6 +34,7 @@ var (
SingleChatMsgRecvSuccessCounter prometheus.Counter
GroupChatMsgRecvSuccessCounter prometheus.Counter
WorkSuperGroupChatMsgRecvSuccessCounter prometheus.Counter
OnlineUserGauge prometheus.Gauge
//msg-msg
SingleChatMsgProcessSuccessCounter prometheus.Counter
@@ -326,6 +327,16 @@ func NewWorkSuperGroupChatMsgRecvSuccessCounter() {
})
}
func NewOnlineUserGauges() {
if OnlineUserGauge != nil {
return
}
OnlineUserGauge = promauto.NewGauge(prometheus.GaugeOpts{
Name: "online_user_num",
Help: "The number of online user num",
})
}
func NewSingleChatMsgProcessSuccessCounter() {
if SingleChatMsgProcessSuccessCounter != nil {
return
+16
View File
@@ -64,3 +64,19 @@ func PromeAdd(counter prometheus.Counter, add int) {
}
}
}
func PromeGaugeInc(gauges prometheus.Gauge) {
if config.Config.Prometheus.Enable {
if gauges != nil {
gauges.Inc()
}
}
}
func PromeGaugeDec(gauges prometheus.Gauge) {
if config.Config.Prometheus.Enable {
if gauges != nil {
gauges.Dec()
}
}
}