internal/ethapi: expose the eth_call gas consumption as a metric #32774

This commit is contained in:
odingaval 2026-02-24 07:29:14 +03:00
parent 14c2408957
commit 13419fa39b

View file

@ -43,6 +43,7 @@ import (
"github.com/ethereum/go-ethereum/eth/tracers/logger"
"github.com/ethereum/go-ethereum/internal/ethapi/override"
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/metrics"
"github.com/ethereum/go-ethereum/p2p"
"github.com/ethereum/go-ethereum/params"
"github.com/ethereum/go-ethereum/rlp"
@ -56,6 +57,8 @@ const estimateGasErrorRatio = 0.015
var errBlobTxNotSupported = errors.New("signing blob transactions not supported")
var errSubClosed = errors.New("chain subscription closed")
var rpcGasUsedEthCall = metrics.NewRegisteredHistogram("rpc/gas_used/eth_call", nil, metrics.NewExpDecaySample(1028, 0.015))
// EthereumAPI provides an API to access Ethereum related information.
type EthereumAPI struct {
b Backend
@ -784,6 +787,7 @@ func (api *BlockChainAPI) Call(ctx context.Context, args TransactionArgs, blockN
if err != nil {
return nil, err
}
rpcGasUsedEthCall.Update(int64(result.UsedGas))
if errors.Is(result.Err, vm.ErrExecutionReverted) {
return nil, newRevertError(result.Revert())
}