remove previous prometheus integration

This commit is contained in:
ionutboangiu
2025-03-27 19:03:02 +02:00
committed by Dan Christian Bogos
parent 934d93ef58
commit 122afad733
12 changed files with 5 additions and 63 deletions

View File

@@ -38,7 +38,6 @@ import (
"github.com/cgrates/cgrates/analyzers"
"github.com/cgrates/cgrates/engine"
"github.com/cgrates/cgrates/utils"
"github.com/prometheus/client_golang/prometheus/promhttp"
"golang.org/x/net/websocket"
)
@@ -188,7 +187,7 @@ func (s *Server) handleRequest(w http.ResponseWriter, r *http.Request) {
io.Copy(w, res)
}
func (s *Server) ServeHTTP(addr, jsonRPCURL, wsRPCURL, promURL, pprofPath string, useBasicAuth bool,
func (s *Server) ServeHTTP(addr, jsonRPCURL, wsRPCURL, pprofPath string, useBasicAuth bool,
userList map[string]string, shdChan *utils.SyncedChan) {
s.RLock()
enabled := s.rpcEnabled
@@ -220,18 +219,6 @@ func (s *Server) ServeHTTP(addr, jsonRPCURL, wsRPCURL, promURL, pprofPath string
s.httpMux.Handle(wsRPCURL, wsHandler)
}
}
if promURL != "" {
s.Lock()
s.httpEnabled = true
s.Unlock()
utils.Logger.Info(fmt.Sprintf("<HTTP> prometheus metrics endpoint registered at %q", promURL))
promHandler := promhttp.Handler()
if useBasicAuth {
s.httpMux.HandleFunc(promURL, use(promHandler.ServeHTTP, basicAuth(userList)))
} else {
s.httpMux.Handle(promURL, promHandler)
}
}
if pprofPath != "" {
s.Lock()
s.httpEnabled = true
@@ -452,7 +439,7 @@ func (s *Server) handleWebSocket(ws *websocket.Conn) {
}
func (s *Server) ServeHTTPTLS(addr, serverCrt, serverKey, caCert string, serverPolicy int,
serverName, jsonRPCURL, wsRPCURL, promURL, pprofPath string,
serverName, jsonRPCURL, wsRPCURL, pprofPath string,
useBasicAuth bool, userList map[string]string, shdChan *utils.SyncedChan) {
s.RLock()
enabled := s.rpcEnabled
@@ -483,18 +470,6 @@ func (s *Server) ServeHTTPTLS(addr, serverCrt, serverKey, caCert string, serverP
s.httpsMux.Handle(wsRPCURL, wsHandler)
}
}
if promURL != "" {
s.Lock()
s.httpEnabled = true
s.Unlock()
utils.Logger.Info(fmt.Sprintf("<HTTPS> prometheus metrics endpoint registered at %q", promURL))
promHandler := promhttp.Handler()
if useBasicAuth {
s.httpsMux.HandleFunc(promURL, use(promHandler.ServeHTTP, basicAuth(userList)))
} else {
s.httpsMux.Handle(promURL, promHandler)
}
}
if pprofPath != "" {
s.Lock()
s.httpEnabled = true

View File

@@ -210,7 +210,6 @@ func testServeHHTPPass(t *testing.T) {
":6555",
cfg.HTTPCfg().HTTPJsonRPCURL,
cfg.HTTPCfg().HTTPWSURL,
cfg.HTTPCfg().PrometheusURL,
cfg.HTTPCfg().PprofPath,
cfg.HTTPCfg().HTTPUseBasicAuth,
cfg.HTTPCfg().HTTPAuthUsers,
@@ -233,7 +232,6 @@ func testServeHHTPPassUseBasicAuth(t *testing.T) {
":56432",
cfg.HTTPCfg().HTTPJsonRPCURL,
cfg.HTTPCfg().HTTPWSURL,
cfg.HTTPCfg().PrometheusURL,
cfg.HTTPCfg().PprofPath,
!cfg.HTTPCfg().HTTPUseBasicAuth,
cfg.HTTPCfg().HTTPAuthUsers,
@@ -257,7 +255,6 @@ func testServeHHTPEnableHttp(t *testing.T) {
utils.EmptyString,
utils.EmptyString,
utils.EmptyString,
utils.EmptyString,
!cfg.HTTPCfg().HTTPUseBasicAuth,
cfg.HTTPCfg().HTTPAuthUsers,
shdChan)
@@ -279,7 +276,6 @@ func testServeHHTPFail(t *testing.T) {
"invalid_port_format",
cfg.HTTPCfg().HTTPJsonRPCURL,
cfg.HTTPCfg().HTTPWSURL,
cfg.HTTPCfg().PrometheusURL,
cfg.HTTPCfg().PprofPath,
cfg.HTTPCfg().HTTPUseBasicAuth,
cfg.HTTPCfg().HTTPAuthUsers,
@@ -305,7 +301,6 @@ func testServeHHTPFailEnableRpc(t *testing.T) {
go server.ServeHTTP(":1000",
cfg.HTTPCfg().HTTPJsonRPCURL,
cfg.HTTPCfg().HTTPWSURL,
cfg.HTTPCfg().PrometheusURL,
cfg.HTTPCfg().PprofPath,
cfg.HTTPCfg().HTTPUseBasicAuth,
cfg.HTTPCfg().HTTPAuthUsers,
@@ -575,7 +570,6 @@ func testServeHTTPTLS(t *testing.T) {
cfg.TLSCfg().ServerName,
cfg.HTTPCfg().HTTPJsonRPCURL,
cfg.HTTPCfg().HTTPWSURL,
cfg.HTTPCfg().PrometheusURL,
cfg.HTTPCfg().PprofPath,
cfg.HTTPCfg().HTTPUseBasicAuth,
cfg.HTTPCfg().HTTPAuthUsers,
@@ -592,7 +586,6 @@ func testServeHTTPTLS(t *testing.T) {
cfg.TLSCfg().ServerName,
cfg.HTTPCfg().HTTPJsonRPCURL,
cfg.HTTPCfg().HTTPWSURL,
cfg.HTTPCfg().PrometheusURL,
cfg.HTTPCfg().PprofPath,
cfg.HTTPCfg().HTTPUseBasicAuth,
cfg.HTTPCfg().HTTPAuthUsers,
@@ -624,7 +617,6 @@ func testServeHTTPTLSWithBasicAuth(t *testing.T) {
cfg.TLSCfg().ServerName,
cfg.HTTPCfg().HTTPJsonRPCURL,
cfg.HTTPCfg().HTTPWSURL,
cfg.HTTPCfg().PrometheusURL,
cfg.HTTPCfg().PprofPath,
!cfg.HTTPCfg().HTTPUseBasicAuth,
cfg.HTTPCfg().HTTPAuthUsers,
@@ -655,7 +647,6 @@ func testServeHTTPTLSError(t *testing.T) {
cfg.TLSCfg().ServerName,
cfg.HTTPCfg().HTTPJsonRPCURL,
cfg.HTTPCfg().HTTPWSURL,
cfg.HTTPCfg().PrometheusURL,
cfg.HTTPCfg().PprofPath,
!cfg.HTTPCfg().HTTPUseBasicAuth,
cfg.HTTPCfg().HTTPAuthUsers,
@@ -687,7 +678,6 @@ func testServeHTTPTLSHttpNotEnabled(t *testing.T) {
utils.EmptyString,
utils.EmptyString,
utils.EmptyString,
utils.EmptyString,
cfg.HTTPCfg().HTTPUseBasicAuth,
cfg.HTTPCfg().HTTPAuthUsers,
shdChan)