Skip to content

Commit

Permalink
Improve logging (#94)
Browse files Browse the repository at this point in the history
  • Loading branch information
evgeniy-scherbina committed Aug 7, 2024
1 parent 9dce811 commit 8dcc1e1
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
14 changes: 9 additions & 5 deletions service/cachemdw/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,15 @@ func IsCacheable(
Msg("can't marshal EVM request params into json")
}

logger.Logger.Error().
Str("method", req.Method).
Str("params", string(paramsInJSON)).
Err(err).
Msg("can't parse block number from params")
// as of now proxy-service doesn't fully support all use-cases of eth_call - so we don't want to log error
// for actually valid requests
if req.Method != "eth_call" {
logger.Logger.Error().
Str("method", req.Method).
Str("params", string(paramsInJSON)).
Err(err).
Msg("can't parse block number from params")
}
return false
}

Expand Down
11 changes: 9 additions & 2 deletions service/shard.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,11 @@ func (hsp PruningOrDefaultProxies) ProxyForRequest(r *http.Request) (*httputil.R
// parse height from the request
height, err := decode.ParseBlockNumberFromParams(decodedReq.Method, decodedReq.Params)
if err != nil {
hsp.Error().Msg(fmt.Sprintf("expected but failed to parse block number for %+v: %s", decodedReq, err))
// as of now proxy-service doesn't fully support all use-cases of eth_call - so we don't want to log error
// for actually valid requests
if decodedReq.Method != "eth_call" {
hsp.Error().Msg(fmt.Sprintf("expected but failed to parse block number for %+v: %s", decodedReq, err))
}
return hsp.defaultProxies.ProxyForRequest(r)
}

Expand Down Expand Up @@ -135,7 +139,10 @@ func (sp ShardProxies) ProxyForRequest(r *http.Request) (*httputil.ReverseProxy,
// parse height from the request
parsedHeight, err := decode.ParseBlockNumberFromParams(decodedReq.Method, decodedReq.Params)
if err != nil {
if err != decode.ErrUncachaebleByBlockNumberEthRequest {
// as of now proxy-service doesn't fully support all use-cases of eth_call - so we don't want to log error
// for actually valid requests
// also we don't want to spam with log errors if request is uncacheable
if decodedReq.Method != "eth_call" && err != decode.ErrUncachaebleByBlockNumberEthRequest {
sp.Error().Msg(fmt.Sprintf("expected but failed to parse block number for %+v: %s", decodedReq, err))
}
return sp.defaultProxies.ProxyForRequest(r)
Expand Down

0 comments on commit 8dcc1e1

Please sign in to comment.