@@ -20,6 +20,7 @@ use crate::{
20
20
#[ derive( Clone ) ]
21
21
pub struct OverlayMetrics {
22
22
pub message_total : IntCounterVec ,
23
+ pub failed_message_sent : IntCounterVec ,
23
24
pub utp_outcome_total : IntCounterVec ,
24
25
pub utp_active_gauge : IntGaugeVec ,
25
26
pub utp_connection_duration : HistogramVec ,
@@ -38,6 +39,14 @@ impl OverlayMetrics {
38
39
& [ "protocol" , "direction" , "type" ] ,
39
40
registry
40
41
) ?;
42
+ let failed_message_sent = register_int_counter_vec_with_registry ! (
43
+ opts!(
44
+ "trin_failed_message_sent" ,
45
+ "count all network messages sent"
46
+ ) ,
47
+ & [ "protocol" , "direction" , "type" ] ,
48
+ registry
49
+ ) ?;
41
50
let utp_outcome_total = register_int_counter_vec_with_registry ! (
42
51
opts!(
43
52
"trin_utp_outcome_total" ,
@@ -80,6 +89,7 @@ impl OverlayMetrics {
80
89
) ?;
81
90
Ok ( Self {
82
91
message_total,
92
+ failed_message_sent,
83
93
utp_outcome_total,
84
94
utp_active_gauge,
85
95
utp_connection_duration,
@@ -129,13 +139,29 @@ impl OverlayMetricsReporter {
129
139
self . increment_message_total ( MessageDirectionLabel :: Received , response. into ( ) ) ;
130
140
}
131
141
142
+ pub fn report_failed_outbound_request ( & self , request : & Request ) {
143
+ self . increment_failed_message_sent ( MessageDirectionLabel :: Sent , request. into ( ) ) ;
144
+ }
145
+
132
146
fn increment_message_total ( & self , direction : MessageDirectionLabel , message : MessageLabel ) {
133
147
let labels: [ & str ; 3 ] = [ & self . protocol , direction. into ( ) , message. into ( ) ] ;
134
148
self . overlay_metrics
135
149
. message_total
136
150
. with_label_values ( & labels)
137
151
. inc ( ) ;
138
152
}
153
+ /// Increment the failed message sent metric
154
+ fn increment_failed_message_sent (
155
+ & self ,
156
+ direction : MessageDirectionLabel ,
157
+ message : MessageLabel ,
158
+ ) {
159
+ let labels: [ & str ; 3 ] = [ & self . protocol , direction. into ( ) , message. into ( ) ] ;
160
+ self . overlay_metrics
161
+ . failed_message_sent
162
+ . with_label_values ( & labels)
163
+ . inc ( ) ;
164
+ }
139
165
/// Increase the total bytes inbound metric by the given length.
140
166
pub fn report_bytes_inbound ( & self , bytes_len : u64 ) {
141
167
let labels: [ & str ; 1 ] = [ & self . protocol ] ;
0 commit comments