metrics: Prometheus endpoint on its own --metrics listener; the pod exposes it inside the cluster only

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AeFqV96dVeBX94inzcgZKw
This commit is contained in:
2026-11-19 10:56:43 +01:00
co-authored by Claude Sonnet 5.5
parent b922808a51
commit c653ae4206
13 changed files with 306 additions and 3 deletions
+33
View File
@@ -0,0 +1,33 @@
package p2p
// Stats is a snapshot of what the node counts about the network, for the
// metrics endpoint. The totals count from the start of the process.
type Stats struct {
Peers int // connected peers
RegionPeers map[string]int // peers known to follow each region we follow
MessagesDropped uint64 // gossip dropped for exceeding a peer's rate
MessagesInvalid uint64 // gossip rejected as invalid
PeersBanned uint64 // peers banned for sending invalid messages
SyncRefused uint64 // sync requests refused (rate, streams, banned)
ConnectionsFull uint64 // inbound connections refused: source address at its limit
ConnectionsBanned uint64 // inbound connections refused: peer banned
}
// Stats returns the current counters.
func (n *Node) Stats() Stats {
s := Stats{
Peers: n.PeerCount(),
RegionPeers: map[string]int{},
MessagesDropped: n.guard.dropped.Load(),
MessagesInvalid: n.guard.invalid.Load(),
PeersBanned: n.guard.bans.Load(),
SyncRefused: n.guard.syncRefused.Load(),
ConnectionsFull: n.gate.refusedFull.Load(),
ConnectionsBanned: n.gate.refusedBanned.Load(),
}
for _, r := range n.Regions() {
s.RegionPeers[r] = len(n.RegionPeers(r))
}
return s
}