fix(metrics): enable prometheus global switch when user enable devsever metrics (#3169)

This commit is contained in:
cong
2023-04-24 20:02:04 +08:00
committed by GitHub
parent 8c9b619199
commit ba9d510cdb
2 changed files with 8 additions and 0 deletions

View File

@@ -10,6 +10,7 @@ import (
"github.com/felixge/fgprof"
"github.com/prometheus/client_golang/prometheus/promhttp"
"github.com/zeromicro/go-zero/core/logx"
"github.com/zeromicro/go-zero/core/prometheus"
"github.com/zeromicro/go-zero/core/threading"
"github.com/zeromicro/go-zero/internal/health"
)
@@ -42,6 +43,8 @@ func (s *Server) addRoutes() {
// metrics
if s.config.EnableMetrics {
// enable prometheus global switch
prometheus.Enable()
s.handleFunc(s.config.MetricsPath, promhttp.Handler().ServeHTTP)
}
// pprof