Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions message/creator.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (

"github.com/ava-labs/avalanchego/utils/compression"
"github.com/ava-labs/avalanchego/utils/logging"
"github.com/ava-labs/avalanchego/utils/metric"
)

var _ Creator = (*creator)(nil)
Expand All @@ -28,14 +27,11 @@ type creator struct {
func NewCreator(
log logging.Logger,
metrics prometheus.Registerer,
parentNamespace string,
compressionType compression.Type,
maxMessageTimeout time.Duration,
) (Creator, error) {
namespace := metric.AppendNamespace(parentNamespace, "codec")
builder, err := newMsgBuilder(
log,
namespace,
metrics,
maxMessageTimeout,
)
Expand Down
2 changes: 0 additions & 2 deletions message/inbound_msg_builder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ func Test_newMsgBuilder(t *testing.T) {

mb, err := newMsgBuilder(
logging.NoLog{},
"test",
prometheus.NewRegistry(),
10*time.Second,
)
Expand Down Expand Up @@ -393,7 +392,6 @@ func TestAppError(t *testing.T) {

mb, err := newMsgBuilder(
logging.NoLog{},
"",
prometheus.NewRegistry(),
time.Second,
)
Expand Down
11 changes: 4 additions & 7 deletions message/messages.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,6 @@ type msgBuilder struct {

func newMsgBuilder(
log logging.Logger,
namespace string,
metrics prometheus.Registerer,
maxMessageTimeout time.Duration,
) (*msgBuilder, error) {
Expand All @@ -164,17 +163,15 @@ func newMsgBuilder(
zstdCompressor: zstdCompressor,
count: prometheus.NewCounterVec(
prometheus.CounterOpts{
Namespace: namespace,
Name: "compressed_count",
Help: "number of compressed messages",
Name: "codec_compressed_count",
Help: "number of compressed messages",
},
metricLabels,
),
duration: prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Namespace: namespace,
Name: "compressed_duration",
Help: "time spent handling compressed messages",
Name: "codec_compressed_duration",
Help: "time spent handling compressed messages",
},
metricLabels,
),
Expand Down
4 changes: 2 additions & 2 deletions message/messages_benchmark_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func BenchmarkMarshalHandshake(b *testing.B) {

useBuilder := os.Getenv("USE_BUILDER") != ""

codec, err := newMsgBuilder(logging.NoLog{}, "", prometheus.NewRegistry(), 10*time.Second)
codec, err := newMsgBuilder(logging.NoLog{}, prometheus.NewRegistry(), 10*time.Second)
require.NoError(err)

b.Logf("proto length %d-byte (use builder %v)", msgLen, useBuilder)
Expand Down Expand Up @@ -119,7 +119,7 @@ func BenchmarkUnmarshalHandshake(b *testing.B) {
require.NoError(err)

useBuilder := os.Getenv("USE_BUILDER") != ""
codec, err := newMsgBuilder(logging.NoLog{}, "", prometheus.NewRegistry(), 10*time.Second)
codec, err := newMsgBuilder(logging.NoLog{}, prometheus.NewRegistry(), 10*time.Second)
require.NoError(err)

b.StartTimer()
Expand Down
4 changes: 0 additions & 4 deletions message/messages_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ func TestMessage(t *testing.T) {

mb, err := newMsgBuilder(
logging.NoLog{},
"test",
prometheus.NewRegistry(),
5*time.Second,
)
Expand Down Expand Up @@ -668,7 +667,6 @@ func TestInboundMessageToString(t *testing.T) {

mb, err := newMsgBuilder(
logging.NoLog{},
"test",
prometheus.NewRegistry(),
5*time.Second,
)
Expand Down Expand Up @@ -699,7 +697,6 @@ func TestEmptyInboundMessage(t *testing.T) {

mb, err := newMsgBuilder(
logging.NoLog{},
"test",
prometheus.NewRegistry(),
5*time.Second,
)
Expand All @@ -720,7 +717,6 @@ func TestNilInboundMessage(t *testing.T) {

mb, err := newMsgBuilder(
logging.NoLog{},
"test",
prometheus.NewRegistry(),
5*time.Second,
)
Expand Down
1 change: 0 additions & 1 deletion message/outbound_msg_builder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ func Test_newOutboundBuilder(t *testing.T) {

mb, err := newMsgBuilder(
logging.NoLog{},
"test",
prometheus.NewRegistry(),
10*time.Second,
)
Expand Down
1 change: 0 additions & 1 deletion network/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ type Config struct {

TLSKeyLogFile string `json:"tlsKeyLogFile"`

Namespace string `json:"namespace"`
MyNodeID ids.NodeID `json:"myNodeID"`
MyIPPort ips.DynamicIPPort `json:"myIP"`
NetworkID uint32 `json:"networkID"`
Expand Down
15 changes: 5 additions & 10 deletions network/ip_tracker.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import (
"github.com/ava-labs/avalanchego/utils/crypto/bls"
"github.com/ava-labs/avalanchego/utils/ips"
"github.com/ava-labs/avalanchego/utils/logging"
"github.com/ava-labs/avalanchego/utils/metric"
"github.com/ava-labs/avalanchego/utils/sampler"
"github.com/ava-labs/avalanchego/utils/set"
)
Expand All @@ -42,25 +41,21 @@ var _ validators.SetCallbackListener = (*ipTracker)(nil)

func newIPTracker(
log logging.Logger,
namespace string,
registerer prometheus.Registerer,
) (*ipTracker, error) {
bloomNamespace := metric.AppendNamespace(namespace, "ip_bloom")
bloomMetrics, err := bloom.NewMetrics(bloomNamespace, registerer)
bloomMetrics, err := bloom.NewMetrics("ip_bloom", registerer)
if err != nil {
return nil, err
}
tracker := &ipTracker{
log: log,
numTrackedIPs: prometheus.NewGauge(prometheus.GaugeOpts{
Namespace: namespace,
Name: "tracked_ips",
Help: "Number of IPs this node is willing to dial",
Name: "tracked_ips",
Help: "Number of IPs this node is willing to dial",
}),
numGossipableIPs: prometheus.NewGauge(prometheus.GaugeOpts{
Namespace: namespace,
Name: "gossipable_ips",
Help: "Number of IPs this node is willing to gossip",
Name: "gossipable_ips",
Help: "Number of IPs this node is willing to gossip",
}),
bloomMetrics: bloomMetrics,
mostRecentTrackedIPs: make(map[ids.NodeID]*ips.ClaimedIPPort),
Expand Down
2 changes: 1 addition & 1 deletion network/ip_tracker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (
)

func newTestIPTracker(t *testing.T) *ipTracker {
tracker, err := newIPTracker(logging.NoLog{}, "", prometheus.NewRegistry())
tracker, err := newIPTracker(logging.NoLog{}, prometheus.NewRegistry())
require.NoError(t, err)
return tracker
}
Expand Down
91 changes: 36 additions & 55 deletions network/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,111 +44,92 @@ type metrics struct {
}

func newMetrics(
namespace string,
registerer prometheus.Registerer,
trackedSubnets set.Set[ids.ID],
) (*metrics, error) {
m := &metrics{
trackedSubnets: trackedSubnets,
numPeers: prometheus.NewGauge(prometheus.GaugeOpts{
Namespace: namespace,
Name: "peers",
Help: "Number of network peers",
Name: "peers",
Help: "Number of network peers",
}),
numTracked: prometheus.NewGauge(prometheus.GaugeOpts{
Namespace: namespace,
Name: "tracked",
Help: "Number of currently tracked IPs attempting to be connected to",
Name: "tracked",
Help: "Number of currently tracked IPs attempting to be connected to",
}),
numSubnetPeers: prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Namespace: namespace,
Name: "peers_subnet",
Help: "Number of peers that are validating a particular subnet",
Name: "peers_subnet",
Help: "Number of peers that are validating a particular subnet",
},
[]string{"subnetID"},
),
timeSinceLastMsgReceived: prometheus.NewGauge(prometheus.GaugeOpts{
Namespace: namespace,
Name: "time_since_last_msg_received",
Help: "Time (in ns) since the last msg was received",
Name: "time_since_last_msg_received",
Help: "Time (in ns) since the last msg was received",
}),
timeSinceLastMsgSent: prometheus.NewGauge(prometheus.GaugeOpts{
Namespace: namespace,
Name: "time_since_last_msg_sent",
Help: "Time (in ns) since the last msg was sent",
Name: "time_since_last_msg_sent",
Help: "Time (in ns) since the last msg was sent",
}),
sendFailRate: prometheus.NewGauge(prometheus.GaugeOpts{
Namespace: namespace,
Name: "send_fail_rate",
Help: "Portion of messages that recently failed to be sent over the network",
Name: "send_fail_rate",
Help: "Portion of messages that recently failed to be sent over the network",
}),
connected: prometheus.NewCounter(prometheus.CounterOpts{
Namespace: namespace,
Name: "times_connected",
Help: "Times this node successfully completed a handshake with a peer",
Name: "times_connected",
Help: "Times this node successfully completed a handshake with a peer",
}),
disconnected: prometheus.NewCounter(prometheus.CounterOpts{
Namespace: namespace,
Name: "times_disconnected",
Help: "Times this node disconnected from a peer it had completed a handshake with",
Name: "times_disconnected",
Help: "Times this node disconnected from a peer it had completed a handshake with",
}),
acceptFailed: prometheus.NewCounter(prometheus.CounterOpts{
Namespace: namespace,
Name: "accept_failed",
Help: "Times this node's listener failed to accept an inbound connection",
Name: "accept_failed",
Help: "Times this node's listener failed to accept an inbound connection",
}),
inboundConnAllowed: prometheus.NewCounter(prometheus.CounterOpts{
Namespace: namespace,
Name: "inbound_conn_throttler_allowed",
Help: "Times this node allowed (attempted to upgrade) an inbound connection",
Name: "inbound_conn_throttler_allowed",
Help: "Times this node allowed (attempted to upgrade) an inbound connection",
}),
tlsConnRejected: prometheus.NewCounter(prometheus.CounterOpts{
Namespace: namespace,
Name: "tls_conn_rejected",
Help: "Times this node rejected a connection due to an unsupported TLS certificate",
Name: "tls_conn_rejected",
Help: "Times this node rejected a connection due to an unsupported TLS certificate",
}),
numUselessPeerListBytes: prometheus.NewCounter(prometheus.CounterOpts{
Namespace: namespace,
Name: "num_useless_peerlist_bytes",
Help: "Amount of useless bytes (i.e. information about nodes we already knew/don't want to connect to) received in PeerList messages",
Name: "num_useless_peerlist_bytes",
Help: "Amount of useless bytes (i.e. information about nodes we already knew/don't want to connect to) received in PeerList messages",
}),
inboundConnRateLimited: prometheus.NewCounter(prometheus.CounterOpts{
Namespace: namespace,
Name: "inbound_conn_throttler_rate_limited",
Help: "Times this node rejected an inbound connection due to rate-limiting",
Name: "inbound_conn_throttler_rate_limited",
Help: "Times this node rejected an inbound connection due to rate-limiting",
}),
nodeUptimeWeightedAverage: prometheus.NewGauge(prometheus.GaugeOpts{
Namespace: namespace,
Name: "node_uptime_weighted_average",
Help: "This node's uptime average weighted by observing peer stakes",
Name: "node_uptime_weighted_average",
Help: "This node's uptime average weighted by observing peer stakes",
}),
nodeUptimeRewardingStake: prometheus.NewGauge(prometheus.GaugeOpts{
Namespace: namespace,
Name: "node_uptime_rewarding_stake",
Help: "The percentage of total stake which thinks this node is eligible for rewards",
Name: "node_uptime_rewarding_stake",
Help: "The percentage of total stake which thinks this node is eligible for rewards",
}),
nodeSubnetUptimeWeightedAverage: prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Namespace: namespace,
Name: "node_subnet_uptime_weighted_average",
Help: "This node's subnet uptime averages weighted by observing subnet peer stakes",
Name: "node_subnet_uptime_weighted_average",
Help: "This node's subnet uptime averages weighted by observing subnet peer stakes",
},
[]string{"subnetID"},
),
nodeSubnetUptimeRewardingStake: prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Namespace: namespace,
Name: "node_subnet_uptime_rewarding_stake",
Help: "The percentage of subnet's total stake which thinks this node is eligible for subnet's rewards",
Name: "node_subnet_uptime_rewarding_stake",
Help: "The percentage of subnet's total stake which thinks this node is eligible for subnet's rewards",
},
[]string{"subnetID"},
),
peerConnectedLifetimeAverage: prometheus.NewGauge(
prometheus.GaugeOpts{
Namespace: namespace,
Name: "peer_connected_duration_average",
Help: "The average duration of all peer connections in nanoseconds",
Name: "peer_connected_duration_average",
Help: "The average duration of all peer connections in nanoseconds",
},
),
peerConnectedStartTimes: make(map[ids.NodeID]float64),
Expand Down
8 changes: 3 additions & 5 deletions network/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,6 @@ func NewNetwork(

inboundMsgThrottler, err := throttling.NewInboundMsgThrottler(
log,
config.Namespace,
metricsRegisterer,
config.Validators,
config.ThrottlerConfig.InboundMsgThrottlerConfig,
Expand All @@ -216,7 +215,6 @@ func NewNetwork(

outboundMsgThrottler, err := throttling.NewSybilOutboundMsgThrottler(
log,
config.Namespace,
metricsRegisterer,
config.Validators,
config.ThrottlerConfig.OutboundMsgThrottlerConfig,
Expand All @@ -225,17 +223,17 @@ func NewNetwork(
return nil, fmt.Errorf("initializing outbound message throttler failed with: %w", err)
}

peerMetrics, err := peer.NewMetrics(config.Namespace, metricsRegisterer)
peerMetrics, err := peer.NewMetrics(metricsRegisterer)
if err != nil {
return nil, fmt.Errorf("initializing peer metrics failed with: %w", err)
}

metrics, err := newMetrics(config.Namespace, metricsRegisterer, config.TrackedSubnets)
metrics, err := newMetrics(metricsRegisterer, config.TrackedSubnets)
if err != nil {
return nil, fmt.Errorf("initializing network metrics failed with: %w", err)
}

ipTracker, err := newIPTracker(log, config.Namespace, metricsRegisterer)
ipTracker, err := newIPTracker(log, metricsRegisterer)
if err != nil {
return nil, fmt.Errorf("initializing ip tracker failed with: %w", err)
}
Expand Down
2 changes: 0 additions & 2 deletions network/network_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ var (

DialerConfig: defaultDialerConfig,

Namespace: "",
NetworkID: 49463,
MaxClockDifference: time.Minute,
PingFrequency: constants.DefaultPingFrequency,
Expand Down Expand Up @@ -196,7 +195,6 @@ func newMessageCreator(t *testing.T) message.Creator {
mc, err := message.NewCreator(
logging.NoLog{},
prometheus.NewRegistry(),
"",
constants.DefaultNetworkCompressionType,
10*time.Second,
)
Expand Down
Loading