aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCliff Lin <zylin@cs.nctu.edu.tw>2019-03-14 11:07:31 +0800
committerWei-Ning Huang <w@byzantine-lab.io>2019-06-12 17:27:22 +0800
commit48066385fe960936758728be34a1d7ae6e9e95a2 (patch)
tree9f98bb467f339e987aab4d549a7ae332f9faefae
parentae057d8eaa31d30d0eebce6e8b76dad368b4a72d (diff)
downloadgo-tangerine-48066385fe960936758728be34a1d7ae6e9e95a2.tar
go-tangerine-48066385fe960936758728be34a1d7ae6e9e95a2.tar.gz
go-tangerine-48066385fe960936758728be34a1d7ae6e9e95a2.tar.bz2
go-tangerine-48066385fe960936758728be34a1d7ae6e9e95a2.tar.lz
go-tangerine-48066385fe960936758728be34a1d7ae6e9e95a2.tar.xz
go-tangerine-48066385fe960936758728be34a1d7ae6e9e95a2.tar.zst
go-tangerine-48066385fe960936758728be34a1d7ae6e9e95a2.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)))
}
}