Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

misc/metrics/: Track address stack #2758

Closed
mxinden opened this issue Jul 17, 2022 · 4 comments · Fixed by #2982
Closed

misc/metrics/: Track address stack #2758

mxinden opened this issue Jul 17, 2022 · 4 comments · Fixed by #2982
Labels
difficulty:easy getting-started Issues that can be tackled if you don't know the internals of libp2p very well help wanted

Comments

@mxinden
Copy link
Member

mxinden commented Jul 17, 2022

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 mxinden added difficulty:easy help wanted getting-started Issues that can be tackled if you don't know the internals of libp2p very well labels Jul 17, 2022
@AbhijithGanesh
Copy link

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

@thomaseizinger
Copy link
Contributor

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

@AbhijithGanesh
Copy link

Got it! thanks for the advice

@AbhijithGanesh
Copy link

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

mxinden pushed a commit to multiformats/rust-multiaddr that referenced this issue Oct 24, 2022
A convenience for cases where _which_ protocols is of concern
but the specific addresses are not, for example
libp2p/rust-libp2p#2758
@mergify mergify bot closed this as completed in #2982 Nov 15, 2022
mergify bot pushed a commit that referenced this issue Nov 15, 2022
Previously, we would only track the metrics like the number of open connections. With this patch, we extend these metrics with a `protocols` label that contains a "protocol stack". A protocol stack is a multi-address with all variable parts removed. For example, `/ip4/127.0.0.1/tcp/1234` turns into `/ip4/tcp`.

Resolves #2758.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
difficulty:easy getting-started Issues that can be tackled if you don't know the internals of libp2p very well help wanted
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants