-
Notifications
You must be signed in to change notification settings - Fork 128
feat(l1): exposing peer related metrics + panel dashboards #5520
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
base: main
Are you sure you want to change the base?
Conversation
Lines of code reportTotal lines added: Detailed view |
| reason: DisconnectReason, | ||
| ) { | ||
| self.peers.fetch_add(1, Ordering::Relaxed); | ||
| self.peers.fetch_sub(1, Ordering::Relaxed); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apparently we were adding peers instead of removing them before.
| if established_state.is_validated { | ||
| // If its validated the peer was connected, so we record the disconnection. | ||
| let reason = established_state | ||
| .disconnect_reason | ||
| .unwrap_or(DisconnectReason::NetworkError); | ||
| METRICS | ||
| .record_new_rlpx_conn_disconnection( | ||
| &established_state | ||
| .node | ||
| .version | ||
| .clone() | ||
| .unwrap_or("Unknown".to_string()), | ||
| reason, | ||
| ) | ||
| .await; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was moved from the Disconnect message handling to the teardown to take into account other reasons for disconnection that were missing previously.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds P2P peer metrics instrumentation to expose peer connectivity data through Prometheus and Grafana dashboards. It addresses a gap in observability by tracking peer counts, client distributions, and disconnection events.
Key Changes:
- Creates new
p2pmetrics module with gauges for peer counts and client distribution, plus counters for disconnections - Fixes a bug where disconnections weren't tracked when peers dropped without explicit Disconnect messages
- Adds comprehensive Grafana dashboard panels with 5 visualizations for peer monitoring
Reviewed changes
Copilot reviewed 13 out of 20 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
crates/blockchain/metrics/p2p.rs |
New module implementing P2P metrics with peer count gauges and disconnection counters |
crates/networking/p2p/metrics.rs |
Updates metric recording logic to properly decrement peer counts and expose to Prometheus |
crates/networking/p2p/rlpx/connection/server.rs |
Adds disconnect reason tracking and validated flag to handle metrics in teardown |
crates/networking/p2p/rlpx/p2p.rs |
Adds all() method and test to ensure all DisconnectReason variants are tracked |
docs/developers/l1/dashboards.md |
Documents new Peer Info dashboard row with panel descriptions |
metrics/provisioning/grafana/dashboards/common_dashboards/ethrex_l1_perf.json |
Adds 5 new Grafana panels for peer visualization |
crates/blockchain/metrics/Cargo.toml |
Updates metrics feature to include prometheus dependency |
cmd/ethrex/Cargo.toml |
Enables metrics feature for ethrex-p2p crate |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
ElFantasma
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! 😎
MegaRedHand
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LFG
Motivation
We want information about the current status of p2p peers in our node.
Description
This PR:
p2pmodule in the metrics cratemetrics.rsmodule in networking (which wasn't exposing metrics to prometheus but to logs instead)