Skip to content

Commit

Permalink
add recvRPC TX metric
Browse files Browse the repository at this point in the history
  • Loading branch information
algorandskiy committed Sep 25, 2024
1 parent c484674 commit 26505e0
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions network/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,9 @@ var transactionMessagesP2PUnderdeliverableMessage = metrics.MakeCounter(metrics.

var networkP2PGossipSubSentBytesTotal = metrics.MakeCounter(metrics.MetricName{Name: "algod_network_p2p_gs_sent_bytes_total", Description: "Total number of bytes sent through gossipsub"})
var networkP2PGossipSubReceivedBytesTotal = metrics.MakeCounter(metrics.MetricName{Name: "algod_network_p2p_gs_received_bytes_total", Description: "Total number of bytes received through gossipsub"})
var networkP2PGossipSubReceivedMsgs = metrics.MakeCounter(metrics.MetricName{Name: "algod_network_p2p_gs_message_received", Description: "Number of complete messages that were received from the network through gossipsub"})

// var networkP2PGossipSubSentMsgs = metrics.MakeCounter(metrics.MetricName{Name: "algod_network_p2p_gs_message_sent", Description: "Number of complete messages that were sent to the network through gossipsub"})

var _ = pubsub.RawTracer(pubsubMetricsTracer{})

Expand Down Expand Up @@ -180,6 +183,14 @@ func (t pubsubMetricsTracer) ThrottlePeer(p peer.ID) {}

// RecvRPC is invoked when an incoming RPC is received.
func (t pubsubMetricsTracer) RecvRPC(rpc *pubsub.RPC) {
for i := range rpc.GetPublish() {
if rpc.Publish[i] != nil && rpc.Publish[i].Topic != nil {
switch *rpc.Publish[i].Topic {
case p2p.TXTopicName:
networkP2PGossipSubReceivedMsgs.Inc(nil)
}
}
}
networkP2PGossipSubReceivedBytesTotal.AddUint64(uint64(rpc.Size()), nil)
}

Expand Down

0 comments on commit 26505e0

Please sign in to comment.