From a180e52a1b2feb8136bbcdadfb3a858237d67444 Mon Sep 17 00:00:00 2001
From: Michal Rostecki <vadorovsky@protonmail.com>
Date: Fri, 13 Dec 2024 16:40:10 +0100
Subject: [PATCH] gossip: Add `save_contact_info_time` metric

Add `save_contact_info_time` metric which measures the time spent by the
`solGossip` thread on fetching and saving contact info.
---
 gossip/src/cluster_info.rs         | 1 +
 gossip/src/cluster_info_metrics.rs | 6 ++++++
 2 files changed, 7 insertions(+)

diff --git a/gossip/src/cluster_info.rs b/gossip/src/cluster_info.rs
index 9f23169c55f512..239c5ca5b84595 100644
--- a/gossip/src/cluster_info.rs
+++ b/gossip/src/cluster_info.rs
@@ -308,6 +308,7 @@ impl ClusterInfo {
     }
 
     pub fn save_contact_info(&self) {
+        let _st = ScopedTimer::from(&self.stats.save_contact_info_time);
         let nodes = {
             let entrypoint_gossip_addrs = self
                 .entrypoints
diff --git a/gossip/src/cluster_info_metrics.rs b/gossip/src/cluster_info_metrics.rs
index 9be73f19759979..b6faced039e1ea 100644
--- a/gossip/src/cluster_info_metrics.rs
+++ b/gossip/src/cluster_info_metrics.rs
@@ -171,6 +171,7 @@ pub struct GossipStats {
     pub(crate) push_vote_read: Counter,
     pub(crate) repair_peers: Counter,
     pub(crate) require_stake_for_gossip_unknown_stakes: Counter,
+    pub(crate) save_contact_info_time: Counter,
     pub(crate) skip_pull_response_shred_version: Counter,
     pub(crate) skip_pull_shred_version: Counter,
     pub(crate) skip_push_message_shred_version: Counter,
@@ -318,6 +319,11 @@ pub(crate) fn submit_gossip_stats(
             stats.push_response_count.clear(),
             i64
         ),
+        (
+            "save_contact_info_time",
+            stats.save_contact_info_time.clear(),
+            i64
+        ),
     );
     datapoint_info!(
         "cluster_info_stats3",