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