go-ethereum/eth
Martin HS 9045b79bc2
metrics, cmd/geth: change init-process of metrics (#30814)
This PR modifies how the metrics library handles `Enabled`: previously,
the package `init` decided whether to serve real metrics or just
dummy-types.

This has several drawbacks: 
- During pkg init, we need to determine whether metrics are enabled or
not. So we first hacked in a check if certain geth-specific
commandline-flags were enabled. Then we added a similar check for
geth-env-vars. Then we almost added a very elaborate check for
toml-config-file, plus toml parsing.

- Using "real" types and dummy types interchangeably means that
everything is hidden behind interfaces. This has a performance penalty,
and also it just adds a lot of code.

This PR removes the interface stuff, uses concrete types, and allows for
the setting of Enabled to happen later. It is still assumed that
`metrics.Enable()` is invoked early on.

The somewhat 'heavy' operations, such as ticking meters and exp-decay,
now checks the enable-flag to prevent resource leak.

The change may be large, but it's mostly pretty trivial, and from the
last time I gutted the metrics, I ensured that we have fairly good test
coverage.

---------

Co-authored-by: Felix Lange <fjl@twurst.com>
2024-12-10 13:27:29 +01:00
..
catalyst eth/downloader: move SyncMode to package eth/ethconfig (#30847) 2024-12-03 09:30:26 +01:00
downloader metrics, cmd/geth: change init-process of metrics (#30814) 2024-12-10 13:27:29 +01:00
ethconfig eth/downloader: move SyncMode to package eth/ethconfig (#30847) 2024-12-03 09:30:26 +01:00
fetcher eth/fetcher: fix blob transaction propagation (#30125) 2024-09-06 13:32:01 +03:00
filters core, eth, node: break rawdb -> {leveldb, pebble} dependency (#30689) 2024-10-29 10:31:04 +02:00
gasestimator core: switch EVM tx context in ApplyMessage (#30809) 2024-11-29 15:39:42 +01:00
gasprice core, eth, ethstats: simplify chain head events (#30601) 2024-10-16 10:32:58 +03:00
protocols metrics, cmd/geth: change init-process of metrics (#30814) 2024-12-10 13:27:29 +01:00
tracers cmd/evm: consolidate evm output switches (#30849) 2024-12-10 09:43:24 +01:00
api_admin.go eth: ignore genesis block on importChain (#27956) 2023-08-21 13:32:34 -04:00
api_backend.go core, eth, internal, cmd: rework EVM constructor (#30745) 2024-11-20 12:35:52 +01:00
api_debug.go miner: refactor the miner, make the pending block on demand (#28623) 2024-03-06 14:45:03 +02:00
api_debug_test.go core/state: state reader abstraction (#29761) 2024-09-05 13:10:47 +03:00
api_miner.go miner: refactor the miner, make the pending block on demand (#28623) 2024-03-06 14:45:03 +02:00
backend.go eth/downloader: move SyncMode to package eth/ethconfig (#30847) 2024-12-03 09:30:26 +01:00
bloombits.go eth: move eth.Config to a common package (#22205) 2021-02-05 13:51:15 +01:00
handler.go metrics, cmd/geth: change init-process of metrics (#30814) 2024-12-10 13:27:29 +01:00
handler_eth.go consensus, cmd, core, eth: remove support for non-merge mode of operation (#29169) 2024-03-05 16:13:28 +02:00
handler_eth_test.go eth/downloader: move SyncMode to package eth/ethconfig (#30847) 2024-12-03 09:30:26 +01:00
handler_snap.go eth: check snap satelliteness, delegate drop to eth (#22235) 2021-02-02 10:44:36 +02:00
handler_test.go eth/downloader: move SyncMode to package eth/ethconfig (#30847) 2024-12-03 09:30:26 +01:00
peer.go eth: remove admin.peers[i].eth.head and difficulty (#26804) 2023-03-06 09:27:46 +02:00
peerset.go consensus, cmd, core, eth: remove support for non-merge mode of operation (#29169) 2024-03-05 16:13:28 +02:00
state_accessor.go core: switch EVM tx context in ApplyMessage (#30809) 2024-11-29 15:39:42 +01:00
sync.go consensus, cmd, core, eth: remove support for non-merge mode of operation (#29169) 2024-03-05 16:13:28 +02:00
sync_test.go eth/downloader: move SyncMode to package eth/ethconfig (#30847) 2024-12-03 09:30:26 +01:00