Register metrics before component start (#27744)

Signed-off-by: wayblink <anyang.wang@zilliz.com>
This commit is contained in:
wayblink 2023-10-19 17:14:10 +08:00 committed by GitHub
parent 635efdf170
commit aa1fba79b1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -250,6 +250,7 @@ func (mr *MilvusRoles) setupLogger() {
// Register serves prometheus http service // Register serves prometheus http service
func setupPrometheusHTTPServer(r *internalmetrics.MilvusRegistry) { func setupPrometheusHTTPServer(r *internalmetrics.MilvusRegistry) {
log.Info("setupPrometheusHTTPServer")
http.Register(&http.Handler{ http.Register(&http.Handler{
Path: "/metrics", Path: "/metrics",
Handler: promhttp.HandlerFor(r, promhttp.HandlerOpts{}), Handler: promhttp.HandlerFor(r, promhttp.HandlerOpts{}),
@ -338,6 +339,7 @@ func (mr *MilvusRoles) Run() {
} }
http.ServeHTTP() http.ServeHTTP()
setupPrometheusHTTPServer(Registry)
var wg sync.WaitGroup var wg sync.WaitGroup
local := mr.Local local := mr.Local
@ -380,7 +382,6 @@ func (mr *MilvusRoles) Run() {
mr.setupLogger() mr.setupLogger()
tracer.Init() tracer.Init()
setupPrometheusHTTPServer(Registry)
paramtable.SetCreateTime(time.Now()) paramtable.SetCreateTime(time.Now())
paramtable.SetUpdateTime(time.Now()) paramtable.SetUpdateTime(time.Now())