Commit d9f058ce authored by Murphy Law's avatar Murphy Law Committed by GitHub

proxyd: Reduce RPC request logging (#2502)

Logging the entire RPC request can be too "expensive" when logging request
objects in a large JSON-RPC batch request. We log the raw HTTP request
body instead so we can truncate effectively when the entire body
exceeds the maxLogLength.
parent 2493e925
---
'@eth-optimism/proxyd': patch
---
proxyd: Reduced RPC request logging
...@@ -27,7 +27,7 @@ const ( ...@@ -27,7 +27,7 @@ const (
MaxBatchRPCCalls = 100 MaxBatchRPCCalls = 100
cacheStatusHdr = "X-Proxyd-Cache-Status" cacheStatusHdr = "X-Proxyd-Cache-Status"
defaultServerTimeout = time.Second * 10 defaultServerTimeout = time.Second * 10
maxLogLength = 1000 maxLogLength = 2000
) )
type Server struct { type Server struct {
...@@ -151,6 +151,12 @@ func (s *Server) HandleRPC(w http.ResponseWriter, r *http.Request) { ...@@ -151,6 +151,12 @@ func (s *Server) HandleRPC(w http.ResponseWriter, r *http.Request) {
} }
RecordRequestPayloadSize(ctx, len(body)) RecordRequestPayloadSize(ctx, len(body))
log.Info("Raw RPC request",
"body", truncate(string(body)),
"req_id", GetReqID(ctx),
"auth", GetAuthCtx(ctx),
)
if IsBatch(body) { if IsBatch(body) {
reqs, err := ParseBatchRPCReq(body) reqs, err := ParseBatchRPCReq(body)
if err != nil { if err != nil {
...@@ -238,12 +244,6 @@ func (s *Server) handleSingleRPC(ctx context.Context, req *RPCReq) (*RPCRes, boo ...@@ -238,12 +244,6 @@ func (s *Server) handleSingleRPC(ctx context.Context, req *RPCReq) (*RPCRes, boo
return NewRPCErrorRes(req.ID, ErrMethodNotWhitelisted), false return NewRPCErrorRes(req.ID, ErrMethodNotWhitelisted), false
} }
log.Info("RPC request",
"method", req.Method,
"params", truncate(string(req.Params)),
"id", truncate(string(req.ID)),
)
var backendRes *RPCRes var backendRes *RPCRes
backendRes, err := s.cache.GetRPC(ctx, req) backendRes, err := s.cache.GetRPC(ctx, req)
if err != nil { if err != nil {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment