@@ -18,6 +18,8 @@ pub struct OverlayMetrics {
1818 pub message_total : IntCounterVec ,
1919 pub utp_outcome_total : IntCounterVec ,
2020 pub utp_active_gauge : IntGaugeVec ,
21+ /// Total bytes transferred inbound
22+ pub bytes_inbound_total : IntCounterVec ,
2123 pub validation_total : IntCounterVec ,
2224}
2325
@@ -47,6 +49,14 @@ impl OverlayMetrics {
4749 & [ "protocol" , "direction" ] ,
4850 registry
4951 ) ?;
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+ ) ?;
5060 let validation_total = register_int_counter_vec_with_registry ! (
5161 opts!(
5262 "trin_validation_total" ,
@@ -59,6 +69,7 @@ impl OverlayMetrics {
5969 message_total,
6070 utp_outcome_total,
6171 utp_active_gauge,
72+ bytes_inbound_total,
6273 validation_total,
6374 } )
6475 }
@@ -111,6 +122,14 @@ impl OverlayMetricsReporter {
111122 . with_label_values ( & labels)
112123 . inc ( ) ;
113124 }
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+ }
114133
115134 //
116135 // uTP metrics
0 commit comments