mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-06-22 22:54:33 +00:00
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:
parent
3c20e08cba
commit
da83b7e392
2 changed files with 8 additions and 0 deletions
|
|
@ -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())
|
||||
}
|
||||
|
|
|
|||
7
internal/ethapi/metrics.go
Normal file
7
internal/ethapi/metrics.go
Normal 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))
|
||||
)
|
||||
Loading…
Reference in a new issue