libp2p / libp2p/rust-libp2p

feat(transport): Metrics oriented connection upgrade

Open
#4,331 8 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

difficulty:hard
Dominant language
Rust
Stars
5.6k
Forks
1.3k
Avg merge
8h 47m
Merged PRs (30d)
19

Description

Description

I am looking for a way to collect aggregate metrics for each stream/substream at the transport level. I think the best way to do this is to create a connection upgrade that just passes buffers through while also sending tuples of timestamp, direction (e.g. in or out), and buffer size over a user-provided bounded channel. I think this would allow upgrading of arbitrary/all streams/sub-streams with each upgraded connection sending their measurements over a bounded mpsc channel to logic that then calculates the aggregate metrics over time.

Motivation

Currently it is not simple/possible to collect metrics for all/some of the network activity at the transport level--below any protocols. These metrics are useful for analytics and debugging as well as nifty "stats for geeks" displays in rust-libp2p applications.

Requirements

  1. Upgrade a connection to add measuring the in/out bytes passing through it.
  2. Report the timestamped and annotated measurements over an mpsc channel if one has been supplied.
  3. Examples for upgrading single connections and all connections along with an example behavior that consumes the metrics and emits behavior events with aggregate metrics based on the config.
  4. Maybe the example network behavior speaks a protocol that allows for the aggregate metrics to be sent over the network to another peer.

Open questions

  1. Is a connection upgrade the correct/best way to do this?
  2. Is the consumption of the measurements and the generation of aggregate metrics best done in a network behavior?

Are you planning to do it yourself in a pull request?

Maybe

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing the transport-level connection upgrade, stream/substream handling, and the proposed bounded mpsc channel. Compare the two open questions about upgrade placement and network-behavior aggregation before deciding on an approach. Done would include connection and all-connection examples plus a behavior example that consumes timestamped, directional byte measurements and emits aggregate metrics.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
networking, observability
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.