Skip to content
This repository has been archived by the owner on Apr 4, 2024. It is now read-only.

imp(rpc) Add support for EVM RPC metrics #1378

Merged
merged 3 commits into from
Oct 14, 2022

Conversation

v-homsi
Copy link
Contributor

@v-homsi v-homsi commented Oct 13, 2022

  • Support --metrics flag
  • Add EVM rpc metrics server config

Closes: #XXX

Description

This PR exposes EVM RPC metrics similar to the ones exposed by go-ethereum.

The metrics correspond to:

  1. Request duration
  2. Count of successful calls
  3. Count of failed calls
  4. The RPC request calls

This PR creates a separate metrics server to serve the metrics for RPC and will be used to expose other EVM/ application metrics in the future.

Based on this discussion, three approaches are identified to exposing the metrics:

  1. Enable the metrics in go-ethereum by passing a hardcoded flag in the CLI --metrics. This option will expose metrics that are not relevant to Ethermint and does not allow for a config file option. This is the approach chosen in this PR.
  2. Intercept the request after or before it's served. This approach would require parsing the request a second time (first time it's parsed in go-ethereum) and Ethermint would not be able to know whether it's successful or not.
  3. Migrate the go-ethereum RPC code to Ethermint and make adjustments to the metrics as needed.

The metrics exposed in this PR correspond to the EVM RPC endpoint as opposed to the tendermint one discussed here. The metrics that will be exposed include latency, number of requests, and the request type.

Sample metrics:

# TYPE rpc_duration_all_count counter
rpc_duration_all_count 19954

# TYPE rpc_duration_all summary
rpc_duration_all {quantile="0.5"} 1.1972705e+06
rpc_duration_all {quantile="0.75"} 8.7099585e+06
rpc_duration_all {quantile="0.95"} 8.960733589999996e+07
rpc_duration_all {quantile="0.99"} 1.0390894278e+08
rpc_duration_all {quantile="0.999"} 1.14853960718e+08
rpc_duration_all {quantile="0.9999"} 1.1498575e+08

# TYPE rpc_duration_eth_blockNumber_success_count counter
rpc_duration_eth_blockNumber_success_count 2

# TYPE rpc_duration_eth_blockNumber_success summary
rpc_duration_eth_blockNumber_success {quantile="0.5"} 507
rpc_duration_eth_blockNumber_success {quantile="0.75"} 681
rpc_duration_eth_blockNumber_success {quantile="0.95"} 681
rpc_duration_eth_blockNumber_success {quantile="0.99"} 681
rpc_duration_eth_blockNumber_success {quantile="0.999"} 681
rpc_duration_eth_blockNumber_success {quantile="0.9999"} 681

# TYPE rpc_duration_eth_chainId_success_count counter
rpc_duration_eth_chainId_success_count 34

# TYPE rpc_duration_eth_chainId_success summary
rpc_duration_eth_chainId_success {quantile="0.5"} 1133.5
rpc_duration_eth_chainId_success {quantile="0.75"} 2806.75
rpc_duration_eth_chainId_success {quantile="0.95"} 6268.25
rpc_duration_eth_chainId_success {quantile="0.99"} 6272
rpc_duration_eth_chainId_success {quantile="0.999"} 6272
rpc_duration_eth_chainId_success {quantile="0.9999"} 6272

# TYPE rpc_duration_eth_estimateGas_success_count counter
rpc_duration_eth_estimateGas_success_count 2

# TYPE rpc_duration_eth_estimateGas_success summary
rpc_duration_eth_estimateGas_success {quantile="0.5"} 9705.5
rpc_duration_eth_estimateGas_success {quantile="0.75"} 9715
rpc_duration_eth_estimateGas_success {quantile="0.95"} 9715
rpc_duration_eth_estimateGas_success {quantile="0.99"} 9715
rpc_duration_eth_estimateGas_success {quantile="0.999"} 9715
rpc_duration_eth_estimateGas_success {quantile="0.9999"} 9715

# TYPE rpc_duration_eth_gasPrice_success_count counter
rpc_duration_eth_gasPrice_success_count 3

# TYPE rpc_duration_eth_gasPrice_success summary
rpc_duration_eth_gasPrice_success {quantile="0.5"} 1236
rpc_duration_eth_gasPrice_success {quantile="0.75"} 1362
rpc_duration_eth_gasPrice_success {quantile="0.95"} 1362
rpc_duration_eth_gasPrice_success {quantile="0.99"} 1362
rpc_duration_eth_gasPrice_success {quantile="0.999"} 1362
rpc_duration_eth_gasPrice_success {quantile="0.9999"} 1362

# TYPE rpc_duration_eth_getBalance_success_count counter
rpc_duration_eth_getBalance_success_count 0

# TYPE rpc_duration_eth_getBalance_success summary
rpc_duration_eth_getBalance_success {quantile="0.5"} 0
rpc_duration_eth_getBalance_success {quantile="0.75"} 0
rpc_duration_eth_getBalance_success {quantile="0.95"} 0
rpc_duration_eth_getBalance_success {quantile="0.99"} 0
rpc_duration_eth_getBalance_success {quantile="0.999"} 0
rpc_duration_eth_getBalance_success {quantile="0.9999"} 0

# TYPE rpc_duration_eth_getBlockByNumber_success_count counter
rpc_duration_eth_getBlockByNumber_success_count 3

# TYPE rpc_duration_eth_getBlockByNumber_success summary
rpc_duration_eth_getBlockByNumber_success {quantile="0.5"} 1623
rpc_duration_eth_getBlockByNumber_success {quantile="0.75"} 1784
rpc_duration_eth_getBlockByNumber_success {quantile="0.95"} 1784
rpc_duration_eth_getBlockByNumber_success {quantile="0.99"} 1784
rpc_duration_eth_getBlockByNumber_success {quantile="0.999"} 1784
rpc_duration_eth_getBlockByNumber_success {quantile="0.9999"} 1784

# TYPE rpc_duration_eth_getTransactionByHash_success_count counter
rpc_duration_eth_getTransactionByHash_success_count 99

# TYPE rpc_duration_eth_getTransactionByHash_success summary
rpc_duration_eth_getTransactionByHash_success {quantile="0.5"} 2151
rpc_duration_eth_getTransactionByHash_success {quantile="0.75"} 3531
rpc_duration_eth_getTransactionByHash_success {quantile="0.95"} 5698
rpc_duration_eth_getTransactionByHash_success {quantile="0.99"} 6231
rpc_duration_eth_getTransactionByHash_success {quantile="0.999"} 6231
rpc_duration_eth_getTransactionByHash_success {quantile="0.9999"} 6231

# TYPE rpc_duration_eth_getTransactionCount_success_count counter
rpc_duration_eth_getTransactionCount_success_count 1136

# TYPE rpc_duration_eth_getTransactionCount_success summary
rpc_duration_eth_getTransactionCount_success {quantile="0.5"} 4439
rpc_duration_eth_getTransactionCount_success {quantile="0.75"} 6791.25
rpc_duration_eth_getTransactionCount_success {quantile="0.95"} 10646.649999999996
rpc_duration_eth_getTransactionCount_success {quantile="0.99"} 12842.739999999998
rpc_duration_eth_getTransactionCount_success {quantile="0.999"} 14244.807999999999
rpc_duration_eth_getTransactionCount_success {quantile="0.9999"} 14252

# TYPE rpc_duration_eth_getTransactionReceipt_success_count counter
rpc_duration_eth_getTransactionReceipt_success_count 854

# TYPE rpc_duration_eth_getTransactionReceipt_success summary
rpc_duration_eth_getTransactionReceipt_success {quantile="0.5"} 95
rpc_duration_eth_getTransactionReceipt_success {quantile="0.75"} 434.25
rpc_duration_eth_getTransactionReceipt_success {quantile="0.95"} 18385.749999999978
rpc_duration_eth_getTransactionReceipt_success {quantile="0.99"} 36295.9
rpc_duration_eth_getTransactionReceipt_success {quantile="0.999"} 42889
rpc_duration_eth_getTransactionReceipt_success {quantile="0.9999"} 42889

# TYPE rpc_duration_eth_sendRawTransaction_success_count counter
rpc_duration_eth_sendRawTransaction_success_count 5

# TYPE rpc_duration_eth_sendRawTransaction_success summary
rpc_duration_eth_sendRawTransaction_success {quantile="0.5"} 1169
rpc_duration_eth_sendRawTransaction_success {quantile="0.75"} 1505.5
rpc_duration_eth_sendRawTransaction_success {quantile="0.95"} 1556
rpc_duration_eth_sendRawTransaction_success {quantile="0.99"} 1556
rpc_duration_eth_sendRawTransaction_success {quantile="0.999"} 1556
rpc_duration_eth_sendRawTransaction_success {quantile="0.9999"} 1556

# TYPE rpc_failure gauge
rpc_failure 0

# TYPE rpc_requests gauge
rpc_requests 19954

# TYPE rpc_success gauge
rpc_success 19954


For contributor use:

  • Targeted PR against correct branch (see CONTRIBUTING.md)
  • Linked to Github issue with discussion and accepted design OR link to spec that describes this work.
  • Code follows the module structure standards.
  • Wrote unit and integration tests
  • Updated relevant documentation (docs/) or specification (x/<module>/spec/)
  • Added relevant godoc comments.
  • Added a relevant changelog entry to the Unreleased section in CHANGELOG.md
  • Re-reviewed Files changed in the Github PR explorer

For admin use:

  • Added appropriate labels to PR (ex. WIP, R4R, docs, etc)
  • Reviewers assigned
  • Squashed all commits, uses message "Merge pull request #XYZ: [title]" (coding standards)

@v-homsi v-homsi requested a review from a team as a code owner October 13, 2022 02:59
@v-homsi v-homsi requested review from hanchon and adisaran64 and removed request for a team October 13, 2022 02:59
@v-homsi v-homsi force-pushed the add_support_for_evm_rpc_metrics branch from 82d6126 to e8cb111 Compare October 13, 2022 03:00
@codecov
Copy link

codecov bot commented Oct 13, 2022

Codecov Report

Merging #1378 (5c4b5ae) into main (22a81b7) will decrease coverage by 0.00%.
The diff coverage is 50.00%.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1378      +/-   ##
==========================================
- Coverage   55.86%   55.86%   -0.01%     
==========================================
  Files         108      108              
  Lines       10015    10017       +2     
==========================================
+ Hits         5595     5596       +1     
- Misses       4139     4140       +1     
  Partials      281      281              
Impacted Files Coverage Δ
server/config/config.go 22.54% <50.00%> (+0.32%) ⬆️

@v-homsi v-homsi force-pushed the add_support_for_evm_rpc_metrics branch 2 times, most recently from 5d82cad to 8519260 Compare October 13, 2022 14:05
- Support --metrics flag
- Add EVM rpc metrics server config
@v-homsi v-homsi force-pushed the add_support_for_evm_rpc_metrics branch from 8519260 to 1f2cb83 Compare October 13, 2022 14:06
server/flags/flags.go Outdated Show resolved Hide resolved
server/start.go Outdated Show resolved Hide resolved
server/start.go Outdated Show resolved Hide resolved
@v-homsi v-homsi force-pushed the add_support_for_evm_rpc_metrics branch from 5a0021e to 66c5829 Compare October 13, 2022 18:13
@v-homsi v-homsi requested a review from facs95 October 14, 2022 02:58
@facs95 facs95 merged commit a21923f into evmos:main Oct 14, 2022
@danburck danburck mentioned this pull request Nov 30, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants