aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCliff Lin <zylin@cs.nctu.edu.tw>2019-03-14 11:07:31 +0800
committerWei-Ning Huang <w@dexon.org>2019-04-09 21:32:58 +0800
commit96340d7e6d81298780888bef417982586ff81466 (patch)
tree17a6bf1fcfd078182c8e8ef6fcc6a79a89a151bb
parenta6580f578e49463eea0e3e89ab0a1c598c3b9ab6 (diff)
downloaddexon-96340d7e6d81298780888bef417982586ff81466.tar.gz
dexon-96340d7e6d81298780888bef417982586ff81466.tar.zst
dexon-96340d7e6d81298780888bef417982586ff81466.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)))
}
}