@@ -148,15 +148,23 @@ pub(crate) struct Metrics {
148148 topic_msg_sent_counts : Family < TopicHash , Counter > ,
149149 /// Bytes from gossip messages sent to each topic.
150150 topic_msg_sent_bytes : Family < TopicHash , Counter > ,
151+ /// Bytes from the last gossip messages sent to each topic.
152+ topic_msg_last_sent_bytes : Family < TopicHash , Gauge > ,
151153 /// Number of gossipsub messages published to each topic.
152154 topic_msg_published : Family < TopicHash , Counter > ,
153155
154156 /// Number of gossipsub messages received on each topic (without filtering duplicates).
155157 topic_msg_recv_counts_unfiltered : Family < TopicHash , Counter > ,
156158 /// Number of gossipsub messages received on each topic (after filtering duplicates).
157159 topic_msg_recv_counts : Family < TopicHash , Counter > ,
158- /// Bytes received from gossip messages for each topic.
160+ /// Bytes received from gossip messages for each topic (after filtering duplicates) .
159161 topic_msg_recv_bytes : Family < TopicHash , Counter > ,
162+ /// Bytes received from last gossip message for each topic (after filtering duplicates).
163+ topic_msg_last_recv_bytes : Family < TopicHash , Gauge > ,
164+ /// Bytes received from gossip messages for each topic (without filtering duplicates).
165+ topic_msg_recv_bytes_unfiltered : Family < TopicHash , Counter > ,
166+ /// Bytes received from last gossip message for each topic (without filtering duplicates).
167+ topic_msg_last_recv_bytes_unfiltered : Family < TopicHash , Gauge > ,
160168
161169 // Metrics related to scoring
162170 /// Histogram of the scores for each mesh topic.
@@ -248,25 +256,35 @@ impl Metrics {
248256 "mesh_peer_counts" ,
249257 "Number of peers in each topic in our mesh"
250258 ) ;
259+
251260 let mesh_peer_inclusion_events = register_family ! (
252261 "mesh_peer_inclusion_events" ,
253262 "Number of times a peer gets added to our mesh for different reasons"
254263 ) ;
264+
255265 let mesh_peer_churn_events = register_family ! (
256266 "mesh_peer_churn_events" ,
257267 "Number of times a peer gets removed from our mesh for different reasons"
258268 ) ;
269+
259270 let topic_msg_sent_counts = register_family ! (
260271 "topic_msg_sent_counts" ,
261272 "Number of gossip messages sent to each topic"
262273 ) ;
274+
263275 let topic_msg_published = register_family ! (
264276 "topic_msg_published" ,
265277 "Number of gossip messages published to each topic"
266278 ) ;
279+
267280 let topic_msg_sent_bytes = register_family ! (
268281 "topic_msg_sent_bytes" ,
269- "Bytes from gossip messages sent to each topic"
282+ "bytes from gossip messages sent to each topic (after duplicates being filtered)"
283+ ) ;
284+
285+ let topic_msg_last_sent_bytes = register_family ! (
286+ "topic_msg_sent_bytes" ,
287+ "bytes from the last gossip message sent to each topic (after duplicates being filtered)"
270288 ) ;
271289
272290 let topic_msg_recv_counts_unfiltered = register_family ! (
@@ -278,9 +296,25 @@ impl Metrics {
278296 "topic_msg_recv_counts" ,
279297 "Number of gossip messages received on each topic (after duplicates have been filtered)"
280298 ) ;
299+
281300 let topic_msg_recv_bytes = register_family ! (
282301 "topic_msg_recv_bytes" ,
283- "Bytes received from gossip messages for each topic"
302+ "Bytes received from gossip messages for each topic (after duplicates being filtered)"
303+ ) ;
304+
305+ let topic_msg_last_recv_bytes = register_family ! (
306+ "topic_msg_last_recv_bytes" ,
307+ "Bytes received from last gossip message for each topic (after duplicates being filtered)"
308+ ) ;
309+
310+ let topic_msg_recv_bytes_unfiltered = register_family ! (
311+ "topic_msg_recv_bytes_unfiltered" ,
312+ "Bytes received from gossip messages for each topic (without duplicates being filtered)"
313+ ) ;
314+
315+ let topic_msg_last_recv_bytes_unfiltered = register_family ! (
316+ "topic_msg_last_recv_bytes_unfiltered" ,
317+ "Bytes received from last gossip message for each topic (without duplicates being filtered)"
284318 ) ;
285319
286320 let hist_builder = HistBuilder {
@@ -390,10 +424,14 @@ impl Metrics {
390424 mesh_peer_churn_events,
391425 topic_msg_sent_counts,
392426 topic_msg_sent_bytes,
427+ topic_msg_last_sent_bytes,
393428 topic_msg_published,
394429 topic_msg_recv_counts_unfiltered,
395430 topic_msg_recv_counts,
396431 topic_msg_recv_bytes,
432+ topic_msg_last_recv_bytes,
433+ topic_msg_recv_bytes_unfiltered,
434+ topic_msg_last_recv_bytes_unfiltered,
397435 score_per_mesh,
398436 scoring_penalties,
399437 peers_per_protocol,
@@ -532,13 +570,22 @@ impl Metrics {
532570 self . topic_msg_sent_bytes
533571 . get_or_create ( topic)
534572 . inc_by ( bytes as u64 ) ;
573+ self . topic_msg_last_sent_bytes
574+ . get_or_create ( topic)
575+ . set ( bytes as i64 ) ;
535576 }
536577 }
537578
538579 /// Register that a message was received (and was not a duplicate).
539- pub ( crate ) fn msg_recvd ( & mut self , topic : & TopicHash ) {
580+ pub ( crate ) fn msg_recvd ( & mut self , topic : & TopicHash , bytes : usize ) {
540581 if self . register_topic ( topic) . is_ok ( ) {
541582 self . topic_msg_recv_counts . get_or_create ( topic) . inc ( ) ;
583+ self . topic_msg_recv_bytes
584+ . get_or_create ( topic)
585+ . inc_by ( bytes as u64 ) ;
586+ self . topic_msg_last_recv_bytes
587+ . get_or_create ( topic)
588+ . set ( bytes as i64 ) ;
542589 }
543590 }
544591
@@ -548,9 +595,12 @@ impl Metrics {
548595 self . topic_msg_recv_counts_unfiltered
549596 . get_or_create ( topic)
550597 . inc ( ) ;
551- self . topic_msg_recv_bytes
598+ self . topic_msg_recv_bytes_unfiltered
552599 . get_or_create ( topic)
553600 . inc_by ( bytes as u64 ) ;
601+ self . topic_msg_last_recv_bytes_unfiltered
602+ . get_or_create ( topic)
603+ . set ( bytes as i64 ) ;
554604 }
555605 }
556606
0 commit comments