rust-libp2p icon indicating copy to clipboard operation
rust-libp2p copied to clipboard

misc/metrics/: Track address stack

Open mxinden opened this issue 2 years ago • 4 comments

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

  1. 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 avatar Jul 17 '22 07:07 mxinden

@mxinden is this issue beginner friendly ? Is this something I could help with ?

AbhijithGanesh avatar Aug 08 '22 11:08 AbhijithGanesh

@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.

thomaseizinger avatar Aug 08 '22 14:08 thomaseizinger

Got it! thanks for the advice

AbhijithGanesh avatar Aug 08 '22 20:08 AbhijithGanesh

I will need some time with this but I will be sending in a PR soon!

AbhijithGanesh avatar Aug 09 '22 18:08 AbhijithGanesh