internal/ethapi: add gas usage metric for eth_call

Add a Prometheus histogram metric (rpc/gas_used/eth_call) that tracks
the gas consumed by eth_call requests. This helps RPC providers monitor
node capacity and correlate CPU usage with actual EVM computation load.

The metric is recorded after successful execution, including reverted
calls, since they still consume gas.

Fixes #32774
This commit is contained in:
TanayK07 2026-03-02 21:28:34 +05:30 committed by Tanayk07
parent 3c20e08cba
commit da83b7e392
2 changed files with 8 additions and 0 deletions

View file

@ -822,6 +822,7 @@ func (api *BlockChainAPI) Call(ctx context.Context, args TransactionArgs, blockN
if err != nil {
return nil, err
}
ethCallGasUsedHist.Update(int64(result.UsedGas))
if errors.Is(result.Err, vm.ErrExecutionReverted) {
return nil, newRevertError(result.Revert())
}

View file

@ -0,0 +1,7 @@
package ethapi
import "github.com/ethereum/go-ethereum/metrics"
var (
ethCallGasUsedHist = metrics.NewRegisteredHistogram("rpc/gas_used/eth_call", nil, metrics.NewExpDecaySample(1028, 0.015))
)