@@ -2,9 +2,10 @@ use std::sync::Arc;
22
33use bittorrent_tracker_core:: torrent:: repository:: in_memory:: InMemoryTorrentRepository ;
44use 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 } ;
66use tokio:: sync:: RwLock ;
77use torrust_tracker_primitives:: torrent_metrics:: TorrentsMetrics ;
8+ use torrust_udp_tracker_server:: statistics as udp_server_statistics;
89
910use crate :: statistics:: metrics:: Metrics ;
1011
@@ -27,12 +28,14 @@ pub async fn get_metrics(
2728 in_memory_torrent_repository : Arc < InMemoryTorrentRepository > ,
2829 ban_service : Arc < RwLock < BanService > > ,
2930 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 > ,
3133) -> TrackerMetrics {
3234 let torrents_metrics = in_memory_torrent_repository. get_torrents_metrics ( ) ;
3335 let udp_banned_ips_total = ban_service. read ( ) . await . get_banned_ips_total ( ) ;
3436 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 ;
3639
3740 TrackerMetrics {
3841 torrents_metrics,
@@ -46,26 +49,26 @@ pub async fn get_metrics(
4649 tcp6_announces_handled : http_stats. tcp6_announces_handled ,
4750 tcp6_scrapes_handled : http_stats. tcp6_scrapes_handled ,
4851 // 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 ,
5154 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 ,
5558 // 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 ,
6265 // 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 ,
6972 } ,
7073 }
7174}
@@ -97,21 +100,27 @@ mod tests {
97100 let in_memory_torrent_repository = Arc :: new ( InMemoryTorrentRepository :: default ( ) ) ;
98101 let ban_service = Arc :: new ( RwLock :: new ( BanService :: new ( MAX_CONNECTION_ID_ERRORS_PER_IP ) ) ) ;
99102
100- // HTTP stats
103+ // HTTP core stats
101104 let ( _http_stats_event_sender, http_stats_repository) =
102105 bittorrent_http_tracker_core:: statistics:: setup:: factory ( config. core . tracker_usage_statistics ) ;
103106 let http_stats_repository = Arc :: new ( http_stats_repository) ;
104107
105- // UDP stats
108+ // UDP core stats
106109 let ( _udp_stats_event_sender, udp_stats_repository) =
107110 bittorrent_udp_tracker_core:: statistics:: setup:: factory ( config. core . tracker_usage_statistics ) ;
108111 let udp_stats_repository = Arc :: new ( udp_stats_repository) ;
109112
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+
110118 let tracker_metrics = get_metrics (
111119 in_memory_torrent_repository. clone ( ) ,
112120 ban_service. clone ( ) ,
113121 http_stats_repository. clone ( ) ,
114122 udp_stats_repository. clone ( ) ,
123+ udp_server_stats_repository. clone ( ) ,
115124 )
116125 . await ;
117126
0 commit comments