More gossipsub metrics (#6873)

N/A


  Add metrics that tell us if a duplicate message that we received was from a mesh peer or from a non mesh peer that we requested with iwant message.
This commit is contained in:
Pawan Dhananjay
2025-01-29 11:42:10 -08:00
committed by GitHub
parent 6973184b06
commit e7ea69647a
3 changed files with 63 additions and 0 deletions

View File

@@ -1841,6 +1841,30 @@ where
peer_score.duplicated_message(propagation_source, &msg_id, &message.topic);
}
self.mcache.observe_duplicate(&msg_id, propagation_source);
// track metrics for the source of the duplicates
if let Some(metrics) = self.metrics.as_mut() {
if self
.mesh
.get(&message.topic)
.is_some_and(|peers| peers.contains(propagation_source))
{
// duplicate was received from a mesh peer
metrics.mesh_duplicates(&message.topic);
} else if self
.gossip_promises
.contains_peer(&msg_id, propagation_source)
{
// duplicate was received from an iwant request
metrics.iwant_duplicates(&message.topic);
} else {
tracing::warn!(
messsage=%msg_id,
peer=%propagation_source,
topic=%message.topic,
"Peer should not have sent message"
);
}
}
return;
}