@@ -2,12 +2,16 @@ use ethportal_api::types::portal_wire::{Request, Response};
2
2
use prometheus_exporter:: {
3
3
self ,
4
4
prometheus:: {
5
- opts, register_int_counter_vec_with_registry, register_int_gauge_vec_with_registry,
5
+ histogram_opts, opts, register_histogram_vec_with_registry,
6
+ register_int_counter_vec_with_registry, register_int_gauge_vec_with_registry, HistogramVec ,
6
7
IntCounterVec , IntGaugeVec , Registry ,
7
8
} ,
8
9
} ;
9
10
10
- use crate :: labels:: { MessageDirectionLabel , MessageLabel , UtpDirectionLabel , UtpOutcomeLabel } ;
11
+ use crate :: {
12
+ labels:: { MessageDirectionLabel , MessageLabel , UtpDirectionLabel , UtpOutcomeLabel } ,
13
+ timer:: DiscardOnDropHistogramTimer ,
14
+ } ;
11
15
12
16
/// Contains metrics reporters for use in the overlay network
13
17
/// (eg. `portalnet/src/overlay.rs` & `portalnet/src/overlay_service.rs`).
@@ -18,6 +22,7 @@ pub struct OverlayMetrics {
18
22
pub message_total : IntCounterVec ,
19
23
pub utp_outcome_total : IntCounterVec ,
20
24
pub utp_active_gauge : IntGaugeVec ,
25
+ pub utp_connection_duration : HistogramVec ,
21
26
pub validation_total : IntCounterVec ,
22
27
}
23
28
@@ -47,6 +52,14 @@ impl OverlayMetrics {
47
52
& [ "protocol" , "direction" ] ,
48
53
registry
49
54
) ?;
55
+ let utp_connection_duration = register_histogram_vec_with_registry ! (
56
+ histogram_opts!(
57
+ "trin_utp_connection_duration" ,
58
+ "the time taken to complete a utp transfer"
59
+ ) ,
60
+ & [ "protocol" , "direction" ] ,
61
+ registry
62
+ ) ?;
50
63
let validation_total = register_int_counter_vec_with_registry ! (
51
64
opts!(
52
65
"trin_validation_total" ,
@@ -59,6 +72,7 @@ impl OverlayMetrics {
59
72
message_total,
60
73
utp_outcome_total,
61
74
utp_active_gauge,
75
+ utp_connection_duration,
62
76
validation_total,
63
77
} )
64
78
}
@@ -157,6 +171,18 @@ impl OverlayMetricsReporter {
157
171
. dec ( ) ;
158
172
}
159
173
174
+ pub fn start_utp_process_timer (
175
+ & self ,
176
+ direction : UtpDirectionLabel ,
177
+ ) -> DiscardOnDropHistogramTimer {
178
+ DiscardOnDropHistogramTimer :: new (
179
+ self . overlay_metrics
180
+ . utp_connection_duration
181
+ . with_label_values ( & [ & self . protocol , direction. into ( ) ] )
182
+ . clone ( ) ,
183
+ )
184
+ }
185
+
160
186
//
161
187
// Validations
162
188
//
0 commit comments