@@ -18,6 +18,8 @@ pub struct OverlayMetrics {
18
18
pub message_total : IntCounterVec ,
19
19
pub utp_outcome_total : IntCounterVec ,
20
20
pub utp_active_gauge : IntGaugeVec ,
21
+ /// Total bytes transferred inbound
22
+ pub bytes_inbound_total : IntCounterVec ,
21
23
pub validation_total : IntCounterVec ,
22
24
}
23
25
@@ -47,6 +49,14 @@ impl OverlayMetrics {
47
49
& [ "protocol" , "direction" ] ,
48
50
registry
49
51
) ?;
52
+ let bytes_inbound_total = register_int_counter_vec_with_registry ! (
53
+ opts!(
54
+ "trin_bytes_inbound_total" ,
55
+ "count all bytes transferred inbound"
56
+ ) ,
57
+ & [ "protocol" ] ,
58
+ registry
59
+ ) ?;
50
60
let validation_total = register_int_counter_vec_with_registry ! (
51
61
opts!(
52
62
"trin_validation_total" ,
@@ -59,6 +69,7 @@ impl OverlayMetrics {
59
69
message_total,
60
70
utp_outcome_total,
61
71
utp_active_gauge,
72
+ bytes_inbound_total,
62
73
validation_total,
63
74
} )
64
75
}
@@ -111,6 +122,14 @@ impl OverlayMetricsReporter {
111
122
. with_label_values ( & labels)
112
123
. inc ( ) ;
113
124
}
125
+ /// Increase the total bytes inbound metric by the given length.
126
+ pub fn report_bytes_inbound ( & self , bytes_len : u64 ) {
127
+ let labels: [ & str ; 1 ] = [ & self . protocol ] ;
128
+ self . overlay_metrics
129
+ . bytes_inbound_total
130
+ . with_label_values ( & labels)
131
+ . inc_by ( bytes_len)
132
+ }
114
133
115
134
//
116
135
// uTP metrics
0 commit comments