mirror of
https://github.com/go-admin-team/go-admin.git
synced 2026-09-20 17:57:54 +00:00
33 lines
680 B
Go
33 lines
680 B
Go
package router
|
|
|
|
import (
|
|
"go-admin/tools/app"
|
|
"net/http"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
log "github.com/go-admin-team/go-admin-core/logger"
|
|
"github.com/go-admin-team/go-admin-core/tools/transfer"
|
|
"github.com/prometheus/client_golang/prometheus/promhttp"
|
|
)
|
|
|
|
func Monitor() {
|
|
var r *gin.Engine
|
|
h := app.Runtime.GetEngine()
|
|
if h == nil {
|
|
h = gin.New()
|
|
app.Runtime.SetEngine(h)
|
|
}
|
|
switch h.(type) {
|
|
case *gin.Engine:
|
|
r = h.(*gin.Engine)
|
|
default:
|
|
log.Fatal("not support other engine")
|
|
}
|
|
//开发环境启动监控指标
|
|
r.GET("/metrics", transfer.Handler(promhttp.Handler()))
|
|
//健康检查
|
|
r.GET("/health", func(c *gin.Context) {
|
|
c.Status(http.StatusOK)
|
|
})
|
|
}
|