Skip to content

Commit 2f10c46

Browse files
authored
feat(network): add connection lifecycle metrics (#11135)
2 parents 9639556 + e1fc2d5 commit 2f10c46

8 files changed

Lines changed: 651 additions & 28 deletions

File tree

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,18 @@ and this project adheres to [Semantic Versioning](https://semver.org).
77

88
## [Unreleased]
99

10+
### Added
11+
12+
- Prometheus metrics now separate peer connection attempts and terminal outcomes by network,
13+
direction, address family, lifecycle stage, and bounded outcome. Version-message metrics also
14+
report the bounded self-reported implementation class without using peer IPs or raw user agents
15+
as labels.
16+
17+
### Changed
18+
19+
- Peer-set, crawler-handshake, and address-book gauges now include a `network` label, so Mainnet
20+
and Testnet values no longer overwrite each other in processes that run both networks.
21+
1022
## [Zebra 6.2.3](https://github.com/ZcashFoundation/zebra/releases/tag/v6.2.3) - 2026-07-27
1123

1224
This is an optional release with network hardenings for operators that experience issues with their nodes peer set connectivity or otherwise want to be proactive about avoiding such issues.

zebra-network/CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
### Added
11+
12+
- Connection-attempt, terminal-outcome, and remote-version metrics with bounded network,
13+
direction, address-family, lifecycle-stage, outcome, and implementation labels.
14+
15+
### Changed
16+
17+
- Peer-set, crawler-handshake, and address-book gauges now include a `network` label, so multiple
18+
network instances in one process do not overwrite each other's values.
19+
1020
## [11.0.0] - 2026-07-27
1121

1222
### Breaking Changes

zebra-network/src/address_book.rs

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ use tracing::Span;
1818
use zebra_chain::{parameters::Network, serialization::DateTime32};
1919

2020
use crate::{
21+
connection_metrics::network_kind_label,
2122
constants::{self, ADDR_RESPONSE_LIMIT_DENOMINATOR, MAX_ADDRS_IN_MESSAGE},
2223
meta_addr::MetaAddrChange,
2324
protocol::external::{canonical_peer_addr, canonical_socket_addr},
@@ -754,15 +755,20 @@ impl AddressBook {
754755
let _ = self.address_metrics_tx.send(m);
755756

756757
// TODO: rename to address_book.[state_name]
757-
metrics::gauge!("candidate_set.responded").set(m.responded as f64);
758-
metrics::gauge!("candidate_set.gossiped").set(m.never_attempted_gossiped as f64);
759-
metrics::gauge!("candidate_set.failed").set(m.failed as f64);
760-
metrics::gauge!("candidate_set.pending").set(m.attempt_pending as f64);
758+
let network = network_kind_label(&self.network);
759+
metrics::gauge!("candidate_set.responded", "network" => network).set(m.responded as f64);
760+
metrics::gauge!("candidate_set.gossiped", "network" => network)
761+
.set(m.never_attempted_gossiped as f64);
762+
metrics::gauge!("candidate_set.failed", "network" => network).set(m.failed as f64);
763+
metrics::gauge!("candidate_set.pending", "network" => network)
764+
.set(m.attempt_pending as f64);
761765

762766
// TODO: rename to address_book.responded.recently_live
763-
metrics::gauge!("candidate_set.recently_live").set(m.recently_live as f64);
767+
metrics::gauge!("candidate_set.recently_live", "network" => network)
768+
.set(m.recently_live as f64);
764769
// TODO: rename to address_book.responded.stopped_responding
765-
metrics::gauge!("candidate_set.disconnected").set(m.recently_stopped_responding as f64);
770+
metrics::gauge!("candidate_set.disconnected", "network" => network)
771+
.set(m.recently_stopped_responding as f64);
766772

767773
std::mem::drop(_guard);
768774
self.log_metrics(&m, instant_now);

0 commit comments

Comments
 (0)