@@ -16,6 +16,7 @@ use crate::labels::{MessageDirectionLabel, MessageLabel, UtpDirectionLabel, UtpO
16
16
#[ derive( Clone ) ]
17
17
pub struct OverlayMetrics {
18
18
pub message_total : IntCounterVec ,
19
+ pub failed_message_sent : IntCounterVec ,
19
20
pub utp_outcome_total : IntCounterVec ,
20
21
pub utp_active_gauge : IntGaugeVec ,
21
22
/// Total bytes transferred inbound
@@ -33,6 +34,14 @@ impl OverlayMetrics {
33
34
& [ "protocol" , "direction" , "type" ] ,
34
35
registry
35
36
) ?;
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
+ ) ?;
36
45
let utp_outcome_total = register_int_counter_vec_with_registry ! (
37
46
opts!(
38
47
"trin_utp_outcome_total" ,
@@ -67,6 +76,7 @@ impl OverlayMetrics {
67
76
) ?;
68
77
Ok ( Self {
69
78
message_total,
79
+ failed_message_sent,
70
80
utp_outcome_total,
71
81
utp_active_gauge,
72
82
bytes_inbound_total,
@@ -115,13 +125,29 @@ impl OverlayMetricsReporter {
115
125
self . increment_message_total ( MessageDirectionLabel :: Received , response. into ( ) ) ;
116
126
}
117
127
128
+ pub fn report_failed_outbound_request ( & self , request : & Request ) {
129
+ self . increment_failed_message_sent ( MessageDirectionLabel :: Sent , request. into ( ) ) ;
130
+ }
131
+
118
132
fn increment_message_total ( & self , direction : MessageDirectionLabel , message : MessageLabel ) {
119
133
let labels: [ & str ; 3 ] = [ & self . protocol , direction. into ( ) , message. into ( ) ] ;
120
134
self . overlay_metrics
121
135
. message_total
122
136
. with_label_values ( & labels)
123
137
. inc ( ) ;
124
138
}
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
+ }
125
151
/// Increase the total bytes inbound metric by the given length.
126
152
pub fn report_bytes_inbound ( & self , bytes_len : u64 ) {
127
153
let labels: [ & str ; 1 ] = [ & self . protocol ] ;
0 commit comments