go-ethereum/eth/protocols/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
..
broadcast.go consensus, cmd, core, eth: remove support for non-merge mode of operation (#29169) 2024-03-05 16:13:28 +02:00
discovery.go eth: dial nodes from discv5 (#30302) 2024-08-15 22:14:42 +02:00
dispatcher.go all: fix function names in docs (#29128) 2024-02-29 11:29:06 +02:00
handler.go metrics, cmd/geth: change init-process of metrics (#30814) 2024-12-10 13:27:29 +01:00
handler_test.go eth/protocols/eth: add ETH68 protocol handler fuzzers (#30417) 2024-11-09 16:07:17 +01:00
handlers.go eth/protocols/eth: remove Requests in block body (#30562) 2024-10-10 10:47:40 +02:00
handshake.go metrics, cmd/geth: change init-process of metrics (#30814) 2024-12-10 13:27:29 +01:00
handshake_test.go cmd/devp2p, eth: drop support for eth/67 (#28956) 2024-02-08 15:49:19 +02:00
metrics.go metrics, cmd/geth: change init-process of metrics (#30814) 2024-12-10 13:27:29 +01:00
peer.go all: use min/max/clear from go1.21 (#29307) 2024-03-21 13:50:13 +01:00
peer_test.go eth: implement eth/68 (#25980) 2022-10-31 16:23:26 +02:00
protocol.go eth/protocols/eth: remove Requests in block body (#30562) 2024-10-10 10:47:40 +02:00
protocol_test.go cmd/devp2p, eth: drop eth/66 (#28239) 2023-10-03 15:03:19 +03:00
tracker.go eth/protocols, prp/tracker: add support for req/rep rtt tracking (#22608) 2021-04-22 11:42:46 +03:00