@@ -16,6 +16,7 @@ use crate::labels::{MessageDirectionLabel, MessageLabel, UtpDirectionLabel, UtpO
1616#[ derive( Clone ) ]
1717pub struct OverlayMetrics {
1818 pub message_total : IntCounterVec ,
19+ pub failed_message_sent : IntCounterVec ,
1920 pub utp_outcome_total : IntCounterVec ,
2021 pub utp_active_gauge : IntGaugeVec ,
2122 /// Total bytes transferred inbound
@@ -33,6 +34,14 @@ impl OverlayMetrics {
3334 & [ "protocol" , "direction" , "type" ] ,
3435 registry
3536 ) ?;
37+ let failed_message_sent = register_int_counter_vec_with_registry ! (
38+ opts!(
39+ "trin_failed_message_sent" ,
40+ "count all network messages sent"
41+ ) ,
42+ & [ "protocol" , "direction" , "type" ] ,
43+ registry
44+ ) ?;
3645 let utp_outcome_total = register_int_counter_vec_with_registry ! (
3746 opts!(
3847 "trin_utp_outcome_total" ,
@@ -67,6 +76,7 @@ impl OverlayMetrics {
6776 ) ?;
6877 Ok ( Self {
6978 message_total,
79+ failed_message_sent,
7080 utp_outcome_total,
7181 utp_active_gauge,
7282 bytes_inbound_total,
@@ -115,13 +125,29 @@ impl OverlayMetricsReporter {
115125 self . increment_message_total ( MessageDirectionLabel :: Received , response. into ( ) ) ;
116126 }
117127
128+ pub fn report_failed_outbound_request ( & self , request : & Request ) {
129+ self . increment_failed_message_sent ( MessageDirectionLabel :: Sent , request. into ( ) ) ;
130+ }
131+
118132 fn increment_message_total ( & self , direction : MessageDirectionLabel , message : MessageLabel ) {
119133 let labels: [ & str ; 3 ] = [ & self . protocol , direction. into ( ) , message. into ( ) ] ;
120134 self . overlay_metrics
121135 . message_total
122136 . with_label_values ( & labels)
123137 . inc ( ) ;
124138 }
139+ /// Increment the failed message sent metric
140+ fn increment_failed_message_sent (
141+ & self ,
142+ direction : MessageDirectionLabel ,
143+ message : MessageLabel ,
144+ ) {
145+ let labels: [ & str ; 3 ] = [ & self . protocol , direction. into ( ) , message. into ( ) ] ;
146+ self . overlay_metrics
147+ . failed_message_sent
148+ . with_label_values ( & labels)
149+ . inc ( ) ;
150+ }
125151 /// Increase the total bytes inbound metric by the given length.
126152 pub fn report_bytes_inbound ( & self , bytes_len : u64 ) {
127153 let labels: [ & str ; 1 ] = [ & self . protocol ] ;
0 commit comments