go-ethereum/eth
Daniel Liu 6beee27886 metrics, cmd/XDC: 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-13 14:00:14 +08:00
..
bft fix vote test and optimize log (#750) 2024-11-29 03:14:25 -08:00
downloader metrics, cmd/XDC: change init-process of metrics (#30814) 2024-12-13 14:00:14 +08:00
ethconfig eth, node: use APPDATA env to support cygwin/msys correctly (#17786) 2024-11-13 09:35:41 +08:00
fetcher all: fix staticcheck warning S1024: not use x.Sub(time.Now()) 2024-10-31 10:49:44 +08:00
filters accounts/abi/bind: fix bounded contracts and sim backend for 1559 (#23038) 2024-11-01 11:36:52 +08:00
gasprice eth/gasprice: reduce default gas price for empty block 2024-11-13 09:30:55 +08:00
hooks fix vote test and optimize log (#750) 2024-11-29 03:14:25 -08:00
tracers all: replace strings.Replace with string.ReplaceAll (#24835) 2024-12-08 11:51:14 +08:00
util Move consensus hooks to its own package 2021-10-10 16:04:32 +11:00
api.go log improvement and some refactor (#110) 2022-07-10 01:11:28 +02:00
api_backend.go eth/gasprice: change feehistory input type from int to uint64 (#26922) 2024-11-01 11:36:53 +08:00
api_test.go all: change format 0x%x to %#x (#25221) 2024-09-27 15:24:31 +08:00
api_tracer.go all: implement EIP-1153 transient storage (#26003) 2024-11-15 19:39:18 +08:00
backend.go eth/gasprice: remove default from config (#30080) 2024-11-13 09:30:55 +08:00
backend_test.go Move consensus hooks to its own package 2021-10-10 16:04:32 +11:00
bloombits.go after we use time.Ticker it didn't allow to have 0 time duration (#493) 2024-03-15 19:07:05 +11:00
handler.go fix vote test and optimize log (#750) 2024-11-29 03:14:25 -08:00
handler_test.go Revert EIP-2464 2024-08-24 02:31:27 +07:00
helper_test.go core: remove unused error from TxPool.Pending (#23720) 2024-11-01 11:36:53 +08:00
metrics.go metrics, cmd/XDC: change init-process of metrics (#30814) 2024-12-13 14:00:14 +08:00
peer.go add flag rpc-gascap and set RPCGasCap to 50M (#664) 2024-10-09 09:28:24 +08:00
protocol.go core: remove unused error from TxPool.Pending (#23720) 2024-11-01 11:36:53 +08:00
protocol_test.go all: replace log15 with slog (#28187) 2024-11-15 10:02:42 +08:00
state_accessor.go add TraceCall, backend.StateAtBlock(), RPCGasCap 2024-05-17 21:34:34 +08:00
sync.go core: remove unused error from TxPool.Pending (#23720) 2024-11-01 11:36:53 +08:00
sync_test.go Revert EIP-2464 2024-08-24 02:31:27 +07:00