Skip to content
Open
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
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
use std::collections::HashMap;
use std::time::Duration;

use apollo_metrics::define_metrics;
use apollo_metrics::metrics::LossyIntoF64;
use apollo_network::metrics::NetworkMetrics;
use apollo_network::metrics::{
BroadcastNetworkMetrics,
NetworkMetrics,
NETWORK_BROADCAST_DROP_LABELS,
};

use crate::protocol::TOPIC;

define_metrics!(
Infra => {
Expand All @@ -20,6 +27,9 @@ define_metrics!(

MetricGauge { NETWORK_CONNECTED_PEERS, "network_connected_peers", "Number of connected peers in the network" },
MetricGauge { NETWORK_BLACKLISTED_PEERS, "network_blacklisted_peers", "Number of blacklisted peers in the network" },
MetricCounter { NETWORK_STRESS_TEST_SENT_MESSAGES, "network_stress_test_sent_messages", "Number of stress test messages sent via broadcast", init = 0 },
MetricCounter { NETWORK_STRESS_TEST_RECEIVED_MESSAGES, "network_stress_test_received_messages", "Number of stress test messages received via broadcast", init = 0 },
LabeledMetricCounter { NETWORK_DROPPED_BROADCAST_MESSAGES, "network_dropped_broadcast_messages", "Number of dropped broadcast messages by reason", init = 0, labels = NETWORK_BROADCAST_DROP_LABELS },
},
);

Expand All @@ -42,12 +52,29 @@ pub fn get_throughput(message_size_bytes: usize, heartbeat_duration: Duration) -
tps * message_size_bytes.into_f64()
}

/// Creates barebones network metrics
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New broadcast metrics are never registered

Medium Severity

The three newly added metrics — NETWORK_STRESS_TEST_SENT_MESSAGES, NETWORK_STRESS_TEST_RECEIVED_MESSAGES, and NETWORK_DROPPED_BROADCAST_MESSAGES — are defined in the define_metrics! macro and wired into BroadcastNetworkMetrics in create_network_metrics(), but register_metrics() was not updated to call .register() on any of them. Without registration, increments to these counters won't be reported by the metrics system, defeating the purpose of this PR.

Additional Locations (1)
Fix in Cursor Fix in Web

pub fn create_network_metrics() -> apollo_network::metrics::NetworkMetrics {
let stress_test_broadcast_metrics = BroadcastNetworkMetrics {
sent_broadcast_message_metrics: apollo_network::metrics::MessageMetrics {
num_messages: NETWORK_STRESS_TEST_SENT_MESSAGES,
message_size_mb: None,
},
dropped_broadcast_message_metrics: apollo_network::metrics::LabeledMessageMetrics {
num_messages: NETWORK_DROPPED_BROADCAST_MESSAGES,
message_size_mb: None,
},
received_broadcast_message_metrics: apollo_network::metrics::MessageMetrics {
num_messages: NETWORK_STRESS_TEST_RECEIVED_MESSAGES,
message_size_mb: None,
},
};

let mut broadcast_metrics_by_topic = HashMap::new();
broadcast_metrics_by_topic.insert(TOPIC.hash(), stress_test_broadcast_metrics);

NetworkMetrics {
num_connected_peers: NETWORK_CONNECTED_PEERS,
num_blacklisted_peers: NETWORK_BLACKLISTED_PEERS,
broadcast_metrics_by_topic: None,
broadcast_metrics_by_topic: Some(broadcast_metrics_by_topic),
sqmr_metrics: None,
event_metrics: None,
latency_metrics: None,
Expand Down
Loading