@@ -281,14 +281,7 @@ impl AptosNetDataClient {
281
281
// Log the peers, periodically.
282
282
sample ! (
283
283
SampleRate :: Duration ( Duration :: from_secs( PEER_LOG_FREQ_SECS ) ) ,
284
- info!(
285
- ( LogSchema :: new( LogEntry :: PeerStates )
286
- . event( LogEvent :: PriorityAndRegularPeers )
287
- . message( & format!(
288
- "Number of priority peers: {:?}. Number of regular peers: {:?}" ,
289
- priority_peers. len( ) , regular_peers. len( ) ,
290
- ) ) )
291
- ) ;
284
+ update_connected_peer_metrics( priority_peers. len( ) , regular_peers. len( ) ) ;
292
285
) ;
293
286
294
287
Ok ( ( priority_peers, regular_peers) )
@@ -701,12 +694,37 @@ fn update_in_flight_metrics(label: &str, num_in_flight_polls: u64) {
701
694
SampleRate :: Frequency ( IN_FLIGHT_METRICS_SAMPLE_FREQ ) ,
702
695
set_gauge(
703
696
& metrics:: IN_FLIGHT_POLLS ,
704
- label. into ( ) ,
697
+ label,
705
698
num_in_flight_polls,
706
699
) ;
707
700
) ;
708
701
}
709
702
703
+ /// Updates the metrics for the number of connected peers (priority and regular)
704
+ fn update_connected_peer_metrics ( num_priority_peers : usize , num_regular_peers : usize ) {
705
+ // Log the number of connected peers
706
+ info ! (
707
+ ( LogSchema :: new( LogEntry :: PeerStates )
708
+ . event( LogEvent :: PriorityAndRegularPeers )
709
+ . message( & format!(
710
+ "Number of priority peers: {:?}. Number of regular peers: {:?}" ,
711
+ num_priority_peers, num_regular_peers,
712
+ ) ) )
713
+ ) ;
714
+
715
+ // Update the connected peer metrics
716
+ set_gauge (
717
+ & metrics:: CONNECTED_PEERS ,
718
+ PRIORITIZED_PEER ,
719
+ num_priority_peers as u64 ,
720
+ ) ;
721
+ set_gauge (
722
+ & metrics:: CONNECTED_PEERS ,
723
+ REGULAR_PEER ,
724
+ num_regular_peers as u64 ,
725
+ ) ;
726
+ }
727
+
710
728
/// Spawns a dedicated poller for the given peer.
711
729
pub ( crate ) fn poll_peer (
712
730
data_client : AptosNetDataClient ,
@@ -793,9 +811,9 @@ fn update_advertised_data_metrics(global_data_summary: GlobalDataSummary) {
793
811
DataType :: TransactionOutputs => optimal_chunk_sizes. transaction_output_chunk_size ,
794
812
DataType :: Transactions => optimal_chunk_sizes. transaction_chunk_size ,
795
813
} ;
796
- metrics :: set_gauge (
814
+ set_gauge (
797
815
& metrics:: OPTIMAL_CHUNK_SIZES ,
798
- data_type. as_str ( ) . into ( ) ,
816
+ data_type. as_str ( ) ,
799
817
optimal_chunk_size,
800
818
) ;
801
819
}
@@ -807,9 +825,9 @@ fn update_advertised_data_metrics(global_data_summary: GlobalDataSummary) {
807
825
. map ( |ledger_info| ledger_info. ledger_info ( ) . version ( ) ) ;
808
826
if let Some ( highest_advertised_version) = highest_advertised_version {
809
827
for data_type in DataType :: get_all_types ( ) {
810
- metrics :: set_gauge (
828
+ set_gauge (
811
829
& metrics:: HIGHEST_ADVERTISED_DATA ,
812
- data_type. as_str ( ) . into ( ) ,
830
+ data_type. as_str ( ) ,
813
831
highest_advertised_version,
814
832
) ;
815
833
}
@@ -824,9 +842,9 @@ fn update_advertised_data_metrics(global_data_summary: GlobalDataSummary) {
824
842
DataType :: Transactions => advertised_data. lowest_transaction_version ( ) ,
825
843
} ;
826
844
if let Some ( lowest_advertised_version) = lowest_advertised_version {
827
- metrics :: set_gauge (
845
+ set_gauge (
828
846
& metrics:: LOWEST_ADVERTISED_DATA ,
829
- data_type. as_str ( ) . into ( ) ,
847
+ data_type. as_str ( ) ,
830
848
lowest_advertised_version,
831
849
) ;
832
850
}
0 commit comments