feat Prometheus

This commit is contained in:
2026-01-16 22:36:18 +08:00
parent 6d5c7e81e9
commit 53cda1ce5e
6 changed files with 23 additions and 71 deletions

View File

@@ -1,7 +1,5 @@
package global
import "github.com/prometheus/client_golang/prometheus"
const (
KeyGatewayAccessToken = "gateway:token:access:%v"
KeyGatewayRefreshToken = "gateway:token:refresh:%v"
@@ -14,7 +12,3 @@ const (
MaxOnlineSize = 100 // 最大在线人数
MaxQueueUpSize = 100 // 最大排队人数
)
var (
OnlineUsersGauge prometheus.Gauge
)

19
internal/global/metric.go Normal file
View File

@@ -0,0 +1,19 @@
package global
import (
"git.hlsq.asia/mmorpg/service-common/log"
"github.com/prometheus/client_golang/prometheus"
)
var (
OnlineUsersGauge prometheus.Gauge
)
func init() {
log.Infof("Init prometheus metric...")
OnlineUsersGauge = prometheus.NewGauge(prometheus.GaugeOpts{
Name: "online_users",
Help: "Total number of online users",
})
prometheus.MustRegister(OnlineUsersGauge)
}