From f574c4e74b12d275d24b209aac8dd98ed9b9bb52 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kurk=C3=B3=20Mih=C3=A1ly?= Date: Fri, 9 Nov 2018 11:20:51 +0200 Subject: [PATCH] metrics, p2p: add ephemeral registry (#18067) * metrics, p2p: add ephemeral registry * metrics: fix linter issue --- metrics/registry.go | 5 ++++- p2p/metrics.go | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/metrics/registry.go b/metrics/registry.go index cc34c9dfd..c1cf7906c 100644 --- a/metrics/registry.go +++ b/metrics/registry.go @@ -311,7 +311,10 @@ func (r *PrefixedRegistry) UnregisterAll() { r.underlying.UnregisterAll() } -var DefaultRegistry Registry = NewRegistry() +var ( + DefaultRegistry = NewRegistry() + EphemeralRegistry = NewRegistry() +) // Call the given function for each registered metric. func Each(f func(string, interface{})) { diff --git a/p2p/metrics.go b/p2p/metrics.go index d7873f39a..8df82bb07 100644 --- a/p2p/metrics.go +++ b/p2p/metrics.go @@ -47,8 +47,8 @@ var ( egressConnectMeter = metrics.NewRegisteredMeter(MetricsOutboundConnects, nil) // Meter counting the egress connections egressTrafficMeter = metrics.NewRegisteredMeter(MetricsOutboundTraffic, nil) // Meter metering the cumulative egress traffic - PeerIngressRegistry = metrics.NewPrefixedChildRegistry(metrics.DefaultRegistry, MetricsInboundTraffic+"/") // Registry containing the peer ingress - PeerEgressRegistry = metrics.NewPrefixedChildRegistry(metrics.DefaultRegistry, MetricsOutboundTraffic+"/") // Registry containing the peer egress + PeerIngressRegistry = metrics.NewPrefixedChildRegistry(metrics.EphemeralRegistry, MetricsInboundTraffic+"/") // Registry containing the peer ingress + PeerEgressRegistry = metrics.NewPrefixedChildRegistry(metrics.EphemeralRegistry, MetricsOutboundTraffic+"/") // Registry containing the peer egress meteredPeerFeed event.Feed // Event feed for peer metrics meteredPeerCount int32 // Actually stored peer connection count