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

feat(metrics)!: expose identify metrics for connected peers only #3325

Merged
merged 10 commits into from
May 15, 2023
5 changes: 3 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion examples/metrics/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ hyper = { version = "0.14", features = ["server", "tcp", "http1"] }
libp2p = { path = "../../libp2p", features = ["async-std", "metrics", "ping", "noise", "identify", "tcp", "yamux", "macros"] }
log = "0.4.0"
tokio = { version = "1", features = ["rt-multi-thread"] }
prometheus-client = "0.20.0"
prometheus-client = "0.21.0"
2 changes: 1 addition & 1 deletion examples/metrics/src/http_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const METRICS_CONTENT_TYPE: &str = "application/openmetrics-text;charset=utf-8;v

pub(crate) async fn metrics_server(registry: Registry) -> Result<(), std::io::Error> {
// Serve on localhost.
let addr = ([127, 0, 0, 1], 0).into();
let addr = ([127, 0, 0, 1], 8080).into();

// Use the tokio runtime to run the hyper server.
let rt = tokio::runtime::Runtime::new()?;
Expand Down
20 changes: 20 additions & 0 deletions misc/metrics/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,29 @@
## 0.13.0 - unreleased

- Previously `libp2p-metrics::identify` would increase a counter / gauge / histogram on each
received identify information. These metrics are misleading, as e.g. they depend on the identify
interval and don't represent the set of currently connected peers. With this change, identify
information is tracked for the currently connected peers only. Instead of an increase on each
received identify information, metrics represent the status quo (Gauge).

Metrics removed:
- `libp2p_identify_protocols`
- `libp2p_identify_received_info_listen_addrs`
- `libp2p_identify_received_info_protocols`
- `libp2p_identify_listen_addresses`

Metrics added:
- `libp2p_identify_remote_protocols`
- `libp2p_identify_remote_listen_addresses`
- `libp2p_identify_local_observed_addresses`

See [PR 3325].

- Raise MSRV to 1.65.
See [PR 3715].

[PR 3715]: https://github.com/libp2p/rust-libp2p/pull/3715
[PR 3325]: https://github.com/libp2p/rust-libp2p/pull/3325

## 0.12.0

Expand Down
3 changes: 2 additions & 1 deletion misc/metrics/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ libp2p-ping = { workspace = true, optional = true }
libp2p-relay = { workspace = true, optional = true }
libp2p-swarm = { workspace = true }
libp2p-identity = { workspace = true }
prometheus-client = "0.20.0"
prometheus-client = { version = "0.21.0" }
once_cell = "1.16.0"

[target.'cfg(not(target_os = "unknown"))'.dependencies]
libp2p-gossipsub = { workspace = true, optional = true }
Expand Down
Loading