@@ -2,9 +2,10 @@ use std::sync::Arc;
2
2
3
3
use bittorrent_tracker_core:: torrent:: repository:: in_memory:: InMemoryTorrentRepository ;
4
4
use bittorrent_udp_tracker_core:: services:: banning:: BanService ;
5
- use bittorrent_udp_tracker_core:: { self , statistics} ;
5
+ use bittorrent_udp_tracker_core:: { self , statistics as udp_core_statistics } ;
6
6
use tokio:: sync:: RwLock ;
7
7
use torrust_tracker_primitives:: torrent_metrics:: TorrentsMetrics ;
8
+ use torrust_udp_tracker_server:: statistics as udp_server_statistics;
8
9
9
10
use crate :: statistics:: metrics:: Metrics ;
10
11
@@ -27,12 +28,14 @@ pub async fn get_metrics(
27
28
in_memory_torrent_repository : Arc < InMemoryTorrentRepository > ,
28
29
ban_service : Arc < RwLock < BanService > > ,
29
30
http_stats_repository : Arc < bittorrent_http_tracker_core:: statistics:: repository:: Repository > ,
30
- udp_stats_repository : Arc < statistics:: repository:: Repository > ,
31
+ udp_core_stats_repository : Arc < udp_core_statistics:: repository:: Repository > ,
32
+ udp_server_stats_repository : Arc < udp_server_statistics:: repository:: Repository > ,
31
33
) -> TrackerMetrics {
32
34
let torrents_metrics = in_memory_torrent_repository. get_torrents_metrics ( ) ;
33
35
let udp_banned_ips_total = ban_service. read ( ) . await . get_banned_ips_total ( ) ;
34
36
let http_stats = http_stats_repository. get_stats ( ) . await ;
35
- let udp_stats = udp_stats_repository. get_stats ( ) . await ;
37
+ let udp_core_stats = udp_core_stats_repository. get_stats ( ) . await ;
38
+ let udp_server_stats = udp_server_stats_repository. get_stats ( ) . await ;
36
39
37
40
TrackerMetrics {
38
41
torrents_metrics,
@@ -46,26 +49,26 @@ pub async fn get_metrics(
46
49
tcp6_announces_handled : http_stats. tcp6_announces_handled ,
47
50
tcp6_scrapes_handled : http_stats. tcp6_scrapes_handled ,
48
51
// UDP
49
- udp_requests_aborted : udp_stats . udp_requests_aborted ,
50
- udp_requests_banned : udp_stats . udp_requests_banned ,
52
+ udp_requests_aborted : udp_server_stats . udp_requests_aborted ,
53
+ udp_requests_banned : udp_server_stats . udp_requests_banned ,
51
54
udp_banned_ips_total : udp_banned_ips_total as u64 ,
52
- udp_avg_connect_processing_time_ns : udp_stats . udp_avg_connect_processing_time_ns ,
53
- udp_avg_announce_processing_time_ns : udp_stats . udp_avg_announce_processing_time_ns ,
54
- udp_avg_scrape_processing_time_ns : udp_stats . udp_avg_scrape_processing_time_ns ,
55
+ udp_avg_connect_processing_time_ns : udp_server_stats . udp_avg_connect_processing_time_ns ,
56
+ udp_avg_announce_processing_time_ns : udp_server_stats . udp_avg_announce_processing_time_ns ,
57
+ udp_avg_scrape_processing_time_ns : udp_server_stats . udp_avg_scrape_processing_time_ns ,
55
58
// UDPv4
56
- udp4_requests : udp_stats . udp4_requests ,
57
- udp4_connections_handled : udp_stats . udp4_connections_handled ,
58
- udp4_announces_handled : udp_stats . udp4_announces_handled ,
59
- udp4_scrapes_handled : udp_stats . udp4_scrapes_handled ,
60
- udp4_responses : udp_stats . udp4_responses ,
61
- udp4_errors_handled : udp_stats . udp4_errors_handled ,
59
+ udp4_requests : udp_server_stats . udp4_requests ,
60
+ udp4_connections_handled : udp_core_stats . udp4_connections_handled ,
61
+ udp4_announces_handled : udp_core_stats . udp4_announces_handled ,
62
+ udp4_scrapes_handled : udp_core_stats . udp4_scrapes_handled ,
63
+ udp4_responses : udp_server_stats . udp4_responses ,
64
+ udp4_errors_handled : udp_server_stats . udp4_errors_handled ,
62
65
// UDPv6
63
- udp6_requests : udp_stats . udp6_requests ,
64
- udp6_connections_handled : udp_stats . udp6_connections_handled ,
65
- udp6_announces_handled : udp_stats . udp6_announces_handled ,
66
- udp6_scrapes_handled : udp_stats . udp6_scrapes_handled ,
67
- udp6_responses : udp_stats . udp6_responses ,
68
- udp6_errors_handled : udp_stats . udp6_errors_handled ,
66
+ udp6_requests : udp_server_stats . udp6_requests ,
67
+ udp6_connections_handled : udp_core_stats . udp6_connections_handled ,
68
+ udp6_announces_handled : udp_core_stats . udp6_announces_handled ,
69
+ udp6_scrapes_handled : udp_core_stats . udp6_scrapes_handled ,
70
+ udp6_responses : udp_server_stats . udp6_responses ,
71
+ udp6_errors_handled : udp_server_stats . udp6_errors_handled ,
69
72
} ,
70
73
}
71
74
}
@@ -97,21 +100,27 @@ mod tests {
97
100
let in_memory_torrent_repository = Arc :: new ( InMemoryTorrentRepository :: default ( ) ) ;
98
101
let ban_service = Arc :: new ( RwLock :: new ( BanService :: new ( MAX_CONNECTION_ID_ERRORS_PER_IP ) ) ) ;
99
102
100
- // HTTP stats
103
+ // HTTP core stats
101
104
let ( _http_stats_event_sender, http_stats_repository) =
102
105
bittorrent_http_tracker_core:: statistics:: setup:: factory ( config. core . tracker_usage_statistics ) ;
103
106
let http_stats_repository = Arc :: new ( http_stats_repository) ;
104
107
105
- // UDP stats
108
+ // UDP core stats
106
109
let ( _udp_stats_event_sender, udp_stats_repository) =
107
110
bittorrent_udp_tracker_core:: statistics:: setup:: factory ( config. core . tracker_usage_statistics ) ;
108
111
let udp_stats_repository = Arc :: new ( udp_stats_repository) ;
109
112
113
+ // UDP server stats
114
+ let ( _udp_server_stats_event_sender, udp_server_stats_repository) =
115
+ torrust_udp_tracker_server:: statistics:: setup:: factory ( config. core . tracker_usage_statistics ) ;
116
+ let udp_server_stats_repository = Arc :: new ( udp_server_stats_repository) ;
117
+
110
118
let tracker_metrics = get_metrics (
111
119
in_memory_torrent_repository. clone ( ) ,
112
120
ban_service. clone ( ) ,
113
121
http_stats_repository. clone ( ) ,
114
122
udp_stats_repository. clone ( ) ,
123
+ udp_server_stats_repository. clone ( ) ,
115
124
)
116
125
. await ;
117
126
0 commit comments