diff --git a/api/api.go b/api/api.go index 6e0c1ba70..5bab4af09 100644 --- a/api/api.go +++ b/api/api.go @@ -85,7 +85,7 @@ func New( Mount(router, "/debug") node.New(nw). Mount(router, "/node") - subs := subscriptions.New(repo, origins, backtraceLimit, txPool, enableMetrics) + subs := subscriptions.New(repo, origins, backtraceLimit, txPool) subs.Mount(router, "/subscriptions") if pprofOn { diff --git a/api/subscriptions/subscriptions.go b/api/subscriptions/subscriptions.go index 89397c9d4..ca5fef83f 100644 --- a/api/subscriptions/subscriptions.go +++ b/api/subscriptions/subscriptions.go @@ -32,7 +32,6 @@ type Subscriptions struct { pendingTx *pendingTx done chan struct{} wg sync.WaitGroup - enableMetrics bool } type msgReader interface { @@ -50,7 +49,7 @@ const ( pingPeriod = (pongWait * 7) / 10 ) -func New(repo *chain.Repository, allowedOrigins []string, backtraceLimit uint32, txpool *txpool.TxPool, enableMetrics bool) *Subscriptions { +func New(repo *chain.Repository, allowedOrigins []string, backtraceLimit uint32, txpool *txpool.TxPool) *Subscriptions { sub := &Subscriptions{ backtraceLimit: backtraceLimit, repo: repo, @@ -69,9 +68,8 @@ func New(repo *chain.Repository, allowedOrigins []string, backtraceLimit uint32, return false }, }, - pendingTx: newPendingTx(txpool), - done: make(chan struct{}), - enableMetrics: enableMetrics, + pendingTx: newPendingTx(txpool), + done: make(chan struct{}), } sub.wg.Add(1) @@ -282,10 +280,7 @@ func (s *Subscriptions) setupConn(w http.ResponseWriter, req *http.Request) (*we }() subject := strings.Split(req.URL.Path, "/")[2] - if s.enableMetrics { - metricsActiveConnectionCount().GaugeWithLabel(1, map[string]string{"subject": subject}) - } - + metricsActiveConnectionCount().GaugeWithLabel(1, map[string]string{"subject": subject}) return conn, closed, subject, nil } @@ -301,10 +296,7 @@ func (s *Subscriptions) closeConn(conn *websocket.Conn, err error, subject strin log.Debug("write close message", "err", err) } - if s.enableMetrics { - metricsActiveConnectionCount().GaugeWithLabel(-1, map[string]string{"subject": subject}) - } - + metricsActiveConnectionCount().GaugeWithLabel(-1, map[string]string{"subject": subject}) if err := conn.Close(); err != nil { log.Debug("close websocket", "err", err) } diff --git a/api/subscriptions/subscriptions_test.go b/api/subscriptions/subscriptions_test.go index 5b2eee023..589a6d58d 100644 --- a/api/subscriptions/subscriptions_test.go +++ b/api/subscriptions/subscriptions_test.go @@ -213,7 +213,7 @@ func initSubscriptionsServer(t *testing.T) { txPool = pool blocks = generatedBlocks router := mux.NewRouter() - sub = New(repo, []string{}, 5, txPool, false) + sub = New(repo, []string{}, 5, txPool) sub.Mount(router, "/subscriptions") ts = httptest.NewServer(router) client = &http.Client{} diff --git a/cmd/thor/main.go b/cmd/thor/main.go index 5a9a63305..267602c70 100644 --- a/cmd/thor/main.go +++ b/cmd/thor/main.go @@ -265,7 +265,6 @@ func defaultAction(ctx *cli.Context) error { uint64(ctx.Int(targetGasLimitFlag.Name)), skipLogs, forkConfig, - ctx.Bool(enableMetricsFlag.Name), ).Run(exitSignal) } diff --git a/cmd/thor/node/node.go b/cmd/thor/node/node.go index 0a3469321..4dfb570b9 100644 --- a/cmd/thor/node/node.go +++ b/cmd/thor/node/node.go @@ -79,7 +79,6 @@ func New( targetGasLimit uint64, skipLogs bool, forkConfig thor.ForkConfig, - enableMetrics bool, ) *Node { return &Node{ packer: packer.New(repo, stater, master.Address(), master.Beneficiary, forkConfig), @@ -94,7 +93,6 @@ func New( targetGasLimit: targetGasLimit, skipLogs: skipLogs, forkConfig: forkConfig, - enableMetrics: enableMetrics, } }