rpc: add a metric for the gas used on eth_call

This commit is contained in:
Mael Regnery 2025-09-29 10:25:26 +02:00
parent 943a30d1ee
commit c112d05ffb
No known key found for this signature in database
GPG key ID: 6B3C0E66C7D94A6F
2 changed files with 28 additions and 0 deletions

View file

@ -775,6 +775,13 @@ func (api *BlockChainAPI) Call(ctx context.Context, args TransactionArgs, blockN
if err != nil {
return nil, err
}
if result.UsedGas > gomath.MaxInt64 {
rpcEthCallGasUsedHist.Update(gomath.MaxInt64)
} else {
rpcEthCallGasUsedHist.Update(int64(result.UsedGas))
}
if errors.Is(result.Err, vm.ErrExecutionReverted) {
return nil, newRevertError(result.Revert())
}

View file

@ -0,0 +1,21 @@
// Copyright 2025 The go-ethereum Authors
// This file is part of the go-ethereum library.
//
// The go-ethereum library is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// The go-ethereum library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
package ethapi
import "github.com/ethereum/go-ethereum/metrics"
var rpcEthCallGasUsedHist = metrics.NewRegisteredHistogram("rpc/gas_used/eth_call", nil, metrics.NewExpDecaySample(1028, 0.015))