mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-02-26 15:47:21 +00:00
rpc: add a metric for the gas used on eth_call
This commit is contained in:
parent
943a30d1ee
commit
c112d05ffb
2 changed files with 28 additions and 0 deletions
|
|
@ -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())
|
||||
}
|
||||
|
|
|
|||
21
internal/ethapi/metrics.go
Normal file
21
internal/ethapi/metrics.go
Normal 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))
|
||||
Loading…
Reference in a new issue