@@ -23,6 +23,8 @@ pub struct OverlayMetrics {
23
23
pub utp_outcome_total : IntCounterVec ,
24
24
pub utp_active_gauge : IntGaugeVec ,
25
25
pub utp_connection_duration : HistogramVec ,
26
+ /// Total bytes transferred inbound
27
+ pub bytes_inbound_total : IntCounterVec ,
26
28
pub validation_total : IntCounterVec ,
27
29
}
28
30
@@ -60,6 +62,14 @@ impl OverlayMetrics {
60
62
& [ "protocol" , "direction" ] ,
61
63
registry
62
64
) ?;
65
+ let bytes_inbound_total = register_int_counter_vec_with_registry ! (
66
+ opts!(
67
+ "trin_bytes_inbound_total" ,
68
+ "count all bytes transferred inbound"
69
+ ) ,
70
+ & [ "protocol" ] ,
71
+ registry
72
+ ) ?;
63
73
let validation_total = register_int_counter_vec_with_registry ! (
64
74
opts!(
65
75
"trin_validation_total" ,
@@ -73,6 +83,7 @@ impl OverlayMetrics {
73
83
utp_outcome_total,
74
84
utp_active_gauge,
75
85
utp_connection_duration,
86
+ bytes_inbound_total,
76
87
validation_total,
77
88
} )
78
89
}
@@ -125,6 +136,14 @@ impl OverlayMetricsReporter {
125
136
. with_label_values ( & labels)
126
137
. inc ( ) ;
127
138
}
139
+ /// Increase the total bytes inbound metric by the given length.
140
+ pub fn report_bytes_inbound ( & self , bytes_len : u64 ) {
141
+ let labels: [ & str ; 1 ] = [ & self . protocol ] ;
142
+ self . overlay_metrics
143
+ . bytes_inbound_total
144
+ . with_label_values ( & labels)
145
+ . inc_by ( bytes_len)
146
+ }
128
147
129
148
//
130
149
// uTP metrics
0 commit comments