mirror of
https://github.com/openimsdk/open-im-server.git
synced 2026-05-12 04:55:59 +08:00
promethues
This commit is contained in:
@@ -99,6 +99,8 @@ type config struct {
|
||||
DBMaxOpenConns int `yaml:"dbMaxOpenConns"`
|
||||
DBMaxIdleConns int `yaml:"dbMaxIdleConns"`
|
||||
DBMaxLifeTime int `yaml:"dbMaxLifeTime"`
|
||||
LogLevel int `yaml:"logLevel"`
|
||||
SlowThreshold int `yaml:"slowThreshold"`
|
||||
}
|
||||
Mongo struct {
|
||||
DBUri string `yaml:"dbUri"`
|
||||
|
||||
@@ -56,10 +56,10 @@ func initMysqlDB() {
|
||||
newLogger := logger.New(
|
||||
Writer{},
|
||||
logger.Config{
|
||||
SlowThreshold: 200 * time.Millisecond, // Slow SQL threshold
|
||||
LogLevel: logger.Warn, // Log level
|
||||
IgnoreRecordNotFoundError: true, // Ignore ErrRecordNotFound error for logger
|
||||
Colorful: true, // Disable color
|
||||
SlowThreshold: time.Duration(config.Config.Mysql.SlowThreshold) * time.Millisecond, // Slow SQL threshold
|
||||
LogLevel: logger.LogLevel(config.Config.Mysql.LogLevel), // Log level
|
||||
IgnoreRecordNotFoundError: true, // Ignore ErrRecordNotFound error for logger
|
||||
Colorful: true, // Disable color
|
||||
},
|
||||
)
|
||||
db, err = gorm.Open(mysql.Open(dsn), &gorm.Config{
|
||||
|
||||
@@ -6,6 +6,7 @@ import (
|
||||
"strconv"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
"github.com/prometheus/client_golang/prometheus/promhttp"
|
||||
)
|
||||
|
||||
@@ -24,3 +25,9 @@ func PrometheusHandler() gin.HandlerFunc {
|
||||
h.ServeHTTP(c.Writer, c.Request)
|
||||
}
|
||||
}
|
||||
|
||||
func PromeInc(counter prometheus.Counter) {
|
||||
if config.Config.Prometheus.Enable {
|
||||
counter.Inc()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user