@@ -42,6 +42,7 @@ import (
4242 "github.com/ethereum/go-ethereum/eth/gasestimator"
4343 "github.com/ethereum/go-ethereum/eth/tracers/logger"
4444 "github.com/ethereum/go-ethereum/log"
45+ "github.com/ethereum/go-ethereum/metrics"
4546 "github.com/ethereum/go-ethereum/p2p"
4647 "github.com/ethereum/go-ethereum/params"
4748 "github.com/ethereum/go-ethereum/rlp"
@@ -52,6 +53,10 @@ import (
5253)
5354
5455var errBlobTxNotSupported = errors .New ("signing blob transactions not supported" )
56+ var (
57+ gasUsedEthEstimateGasGauge = metrics .NewRegisteredCounter ("rpc/gas_used/eth_estimategas" , nil )
58+ gasUsedEthCallGauge = metrics .NewRegisteredCounter ("rpc/gas_used/eth_call" , nil )
59+ )
5560
5661func fallbackClientFor (b Backend , err error ) types.FallbackClient {
5762 if ! errors .Is (err , types .ErrUseFallback ) {
@@ -1242,6 +1247,7 @@ func (s *BlockChainAPI) Call(ctx context.Context, args TransactionArgs, blockNrO
12421247 if len (result .Revert ()) > 0 {
12431248 return nil , newRevertError (result .Revert ())
12441249 }
1250+ gasUsedEthCallGauge .Inc (int64 (result .UsedGas ))
12451251 return result .Return (), result .Err
12461252}
12471253
@@ -1312,6 +1318,9 @@ func (s *BlockChainAPI) EstimateGas(ctx context.Context, args TransactionArgs, b
13121318 err := client .CallContext (ctx , & res , "eth_estimateGas" , args , blockNrOrHash , overrides )
13131319 return res , err
13141320 }
1321+ if err != nil {
1322+ gasUsedEthEstimateGasGauge .Inc (int64 (res ))
1323+ }
13151324 return res , err
13161325}
13171326
0 commit comments