ipld-eth-server http counters don't work #211

Closed
opened 2022-12-22 22:22:14 +00:00 by telackey · 2 comments
Member

I noticed in grafana that the stats for HTTP counters were constantly flat. At first glance, it doesn't look like the prom "middleware" code is used anywhere for HTTP (compare to WS).

Fixing this is probably as simple as the following patch, I just need to confirm:

diff --git a/pkg/rpc/http.go b/pkg/rpc/http.go
index 9e1b2b86..861f6951 100644
--- a/pkg/rpc/http.go
+++ b/pkg/rpc/http.go
@@ -23,6 +23,8 @@ import (
        "github.com/ethereum/go-ethereum/node"
        "github.com/ethereum/go-ethereum/rpc"
        log "github.com/sirupsen/logrus"
+
+       "github.com/cerc-io/ipld-eth-server/v4/pkg/prom"
 )

 // StartHTTPEndpoint starts the HTTP RPC endpoint, configured with cors/vhosts/modules.
@@ -34,6 +36,7 @@ func StartHTTPEndpoint(endpoint string, apis []rpc.API, modules []string, cors [
                utils.Fatalf("Could not register HTTP API: %w", err)
        }
        handler := node.NewHTTPHandlerStack(srv, cors, vhosts, nil)
+       handler = prom.HTTPMiddleware(handler)

        // start http server
        _, addr, err := node.StartHTTPEndpoint(endpoint, rpc.DefaultHTTPTimeouts, handler)
I noticed in grafana that the stats for HTTP counters were constantly flat. At first glance, it doesn't look like the prom "middleware" code is used anywhere for HTTP (compare to WS). Fixing this is probably as simple as the following patch, I just need to confirm: ``` diff --git a/pkg/rpc/http.go b/pkg/rpc/http.go index 9e1b2b86..861f6951 100644 --- a/pkg/rpc/http.go +++ b/pkg/rpc/http.go @@ -23,6 +23,8 @@ import ( "github.com/ethereum/go-ethereum/node" "github.com/ethereum/go-ethereum/rpc" log "github.com/sirupsen/logrus" + + "github.com/cerc-io/ipld-eth-server/v4/pkg/prom" ) // StartHTTPEndpoint starts the HTTP RPC endpoint, configured with cors/vhosts/modules. @@ -34,6 +36,7 @@ func StartHTTPEndpoint(endpoint string, apis []rpc.API, modules []string, cors [ utils.Fatalf("Could not register HTTP API: %w", err) } handler := node.NewHTTPHandlerStack(srv, cors, vhosts, nil) + handler = prom.HTTPMiddleware(handler) // start http server _, addr, err := node.StartHTTPEndpoint(endpoint, rpc.DefaultHTTPTimeouts, handler) ```
Member

That's correct, see also https://github.com/cerc-io/ipld-eth-server/issues/133 they were accidentally removed

That's correct, see also https://github.com/cerc-io/ipld-eth-server/issues/133 they were accidentally removed
Member

Late to the party, thanks for fixing this!

Late to the party, thanks for fixing this!
Sign in to join this conversation.
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: cerc-io/ipld-eth-server#211
No description provided.