rust-libp2p
rust-libp2p copied to clipboard
misc/metrics/: Track address stack
Description
In order to answer questions like:
- Do most of the connections to remote peers use IPv4 or IPv6? TCP, Quic or WebRTC? ...
- What protocols do remote peers support? IPv4 or IPv6? TCP, Quic or WebRTC?
I think we should expose metrics like:
libp2p_swarm_connections_incoming{address_stack="/ip4/tcp/"} 42
libp2p_swarm_connections_incoming{address_stack="/ip4/udp/quic/"} 42
and
# HELP: Number of connected nodes supporting a specific listen address stack, with "unrecognized\" for each peer supporting one or more unrecognized protocols.
libp2p_identify_listen_addresses{address_stack="/ip4/tcp/"} 42
Requirements
- A way to strip a
Multiaddr
of the variable parts (e.g. concrete IP or concrete port) to prevent a cardinality explosion. See example implementation https://github.com/mxinden/kademlia-exporter/blob/7c6ced0c857152f8798a54d89648c54f65d47817/src/exporter/node_store.rs#L318-L358
Open questions
Are you planning to do it yourself in a pull request?
Not any time soon. Happy to help contributors.
@mxinden is this issue beginner friendly ? Is this something I could help with ?
@mxinden is this issue beginner friendly ? Is this something I could help with ?
Yes it should be.
Take a look at how other metrics are implemented for some inspiration.
You'll have to use a Gauge
as the underlying metric and increment/decrement based on the information in SwarmEvent
.
Got it! thanks for the advice
I will need some time with this but I will be sending in a PR soon!