aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCliff Lin <zylin@cs.nctu.edu.tw>2019-03-14 11:07:31 +0800
committerGitHub <noreply@github.com>2019-03-14 11:07:31 +0800
commit206035f286f375c198451b778ff8884a2357c5b1 (patch)
tree40a95c64955c1025189007555e1e31c3c48485d1
parent662cccb5ec127969d6e939fad3e95db021822683 (diff)
downloaddexon-206035f286f375c198451b778ff8884a2357c5b1.tar.gz
dexon-206035f286f375c198451b778ff8884a2357c5b1.tar.zst
dexon-206035f286f375c198451b778ff8884a2357c5b1.zip
p2p: report peer counts to datadog (#254)
-rw-r--r--p2p/metrics.go2
-rw-r--r--p2p/server.go2
2 files changed, 4 insertions, 0 deletions
diff --git a/p2p/metrics.go b/p2p/metrics.go
index 4ed164431..1e90d3e34 100644
--- a/p2p/metrics.go
+++ b/p2p/metrics.go
@@ -39,6 +39,7 @@ const (
MetricsOutboundTraffic = "p2p/OutboundTraffic" // Name for the registered outbound traffic meter
MetricsLatency = "p2p/Latency" // Name for the registered Latency gauge
MetricsRelativeLatency = "p2p/RelativeLatency" // Name for the registered Relative Latency gauge
+ MetricsPeerCount = "p2p/PeerCounts" // Name for the registered Peer Counts
MeteredPeerLimit = 1024 // This amount of peers are individually metered
)
@@ -57,6 +58,7 @@ var (
peerLatency = metrics.NewRegisteredGauge(MetricsLatency, nil) // Gauge latency
peerRelativeLatency = metrics.NewRegisteredGauge(MetricsRelativeLatency, nil) // Gauge Relative latency
+ peerCounts = metrics.NewRegisteredGauge(MetricsPeerCount, nil)
)
// MeteredPeerEventType is the type of peer events emitted by a metered connection.
diff --git a/p2p/server.go b/p2p/server.go
index 58b76a708..c1cf0f9fe 100644
--- a/p2p/server.go
+++ b/p2p/server.go
@@ -808,6 +808,7 @@ running:
}
name := truncateName(c.name)
srv.log.Debug("Adding p2p peer", "name", name, "addr", c.fd.RemoteAddr(), "peers", len(peers)+1)
+ peerCounts.Update(int64((len(peers) + 1)))
go srv.runPeer(p)
peers[c.node.ID()] = p
if p.Inbound() {
@@ -830,6 +831,7 @@ running:
if pd.Inbound() {
inboundCount--
}
+ peerCounts.Update(int64(len(peers)))
}
}