mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-12-07 13:07:09 +08:00
fix:prometheus enable function
This commit is contained in:
parent
419c97cd4a
commit
c6fabc308e
@ -18,7 +18,7 @@ import (
|
||||
"context"
|
||||
"fmt"
|
||||
ginProm "github.com/openimsdk/open-im-server/v3/pkg/common/ginPrometheus"
|
||||
prom_metrics "github.com/openimsdk/open-im-server/v3/pkg/common/prom_metrics"
|
||||
"github.com/openimsdk/open-im-server/v3/pkg/common/prom_metrics"
|
||||
"net"
|
||||
_ "net/http/pprof"
|
||||
"strconv"
|
||||
@ -85,10 +85,11 @@ func run(port int, proPort int) error {
|
||||
log.ZInfo(context.Background(), "api register public config to discov success")
|
||||
router := api.NewGinRouter(client, rdb)
|
||||
//////////////////////////////
|
||||
p := ginProm.NewPrometheus("app", prom_metrics.GetGinCusMetrics("Api"))
|
||||
|
||||
p.SetListenAddress(fmt.Sprintf(":%d", proPort))
|
||||
p.Use(router)
|
||||
if config.Config.Prometheus.Enable {
|
||||
p := ginProm.NewPrometheus("app", prom_metrics.GetGinCusMetrics("Api"))
|
||||
p.SetListenAddress(fmt.Sprintf(":%d", proPort))
|
||||
p.Use(router)
|
||||
}
|
||||
/////////////////////////////////
|
||||
log.ZInfo(context.Background(), "api init router success")
|
||||
var address string
|
||||
|
||||
@ -83,7 +83,6 @@ func Start(
|
||||
if err != nil {
|
||||
return utils.Wrap1(err)
|
||||
}
|
||||
metric.InitializeMetrics(srv)
|
||||
err = client.Register(
|
||||
rpcRegisterName,
|
||||
registerIP,
|
||||
@ -95,6 +94,7 @@ func Start(
|
||||
}
|
||||
go func() {
|
||||
if config.Config.Prometheus.Enable && prometheusPort != 0 {
|
||||
metric.InitializeMetrics(srv)
|
||||
// Create a HTTP server for prometheus.
|
||||
httpServer := &http.Server{Handler: promhttp.HandlerFor(reg, promhttp.HandlerOpts{}), Addr: fmt.Sprintf("0.0.0.0:%d", prometheusPort)}
|
||||
if err := httpServer.ListenAndServe(); err != nil {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user