@@ -27,39 +27,13 @@ pub struct TrackerMetrics {
2727/// It returns all the [`TrackerMetrics`]
2828pub async fn get_metrics (
2929 in_memory_torrent_repository : Arc < InMemoryTorrentRepository > ,
30- ban_service : Arc < RwLock < BanService > > ,
3130 tracker_core_stats_repository : Arc < bittorrent_tracker_core:: statistics:: repository:: Repository > ,
3231 http_stats_repository : Arc < bittorrent_http_tracker_core:: statistics:: repository:: Repository > ,
3332 udp_server_stats_repository : Arc < udp_server_statistics:: repository:: Repository > ,
3433) -> TrackerMetrics {
35- let protocol_metrics_from_global_metrics = get_protocol_metrics (
36- ban_service. clone ( ) ,
37- http_stats_repository. clone ( ) ,
38- udp_server_stats_repository. clone ( ) ,
39- )
40- . await ;
41-
42- let protocol_metrics_from_labeled_metrics =
43- get_protocol_metrics_from_labeled_metrics ( http_stats_repository. clone ( ) , udp_server_stats_repository. clone ( ) ) . await ;
44-
45- // todo:
46- // We keep both metrics until we deploy to production and we can
47- // ensure that the protocol metrics from labeled metrics are correct.
48- // After that we can remove the `get_protocol_metrics` function and
49- // use only the `get_protocol_metrics_from_labeled_metrics` function.
50- // And also remove the code in repositories to generate the global metrics.
51- let protocol_metrics = if protocol_metrics_from_global_metrics == protocol_metrics_from_labeled_metrics {
52- protocol_metrics_from_labeled_metrics
53- } else {
54- tracing:: warn!( "The protocol metrics from global metrics and labeled metrics are different" ) ;
55- tracing:: warn!( "Global metrics: {:?}" , protocol_metrics_from_global_metrics) ;
56- tracing:: warn!( "Labeled metrics: {:?}" , protocol_metrics_from_labeled_metrics) ;
57- protocol_metrics_from_global_metrics
58- } ;
59-
6034 TrackerMetrics {
6135 torrents_metrics : get_torrents_metrics ( in_memory_torrent_repository, tracker_core_stats_repository) . await ,
62- protocol_metrics,
36+ protocol_metrics : get_protocol_metrics ( http_stats_repository . clone ( ) , udp_server_stats_repository . clone ( ) ) . await ,
6337 }
6438}
6539
@@ -76,57 +50,9 @@ async fn get_torrents_metrics(
7650 torrents_metrics
7751}
7852
79- #[ allow( deprecated) ]
80- async fn get_protocol_metrics (
81- ban_service : Arc < RwLock < BanService > > ,
82- http_stats_repository : Arc < bittorrent_http_tracker_core:: statistics:: repository:: Repository > ,
83- udp_server_stats_repository : Arc < udp_server_statistics:: repository:: Repository > ,
84- ) -> ProtocolMetrics {
85- let udp_banned_ips_total = ban_service. read ( ) . await . get_banned_ips_total ( ) ;
86- let http_stats = http_stats_repository. get_stats ( ) . await ;
87- let udp_server_stats = udp_server_stats_repository. get_stats ( ) . await ;
88-
89- // For backward compatibility we keep the `tcp4_connections_handled` and
90- // `tcp6_connections_handled` metrics. They don't make sense for the HTTP
91- // tracker, but we keep them for now. In new major versions we should remove
92- // them.
93-
94- ProtocolMetrics {
95- // TCPv4
96- tcp4_connections_handled : http_stats. tcp4_announces_handled ( ) + http_stats. tcp4_scrapes_handled ( ) ,
97- tcp4_announces_handled : http_stats. tcp4_announces_handled ( ) ,
98- tcp4_scrapes_handled : http_stats. tcp4_scrapes_handled ( ) ,
99- // TCPv6
100- tcp6_connections_handled : http_stats. tcp6_announces_handled ( ) + http_stats. tcp6_scrapes_handled ( ) ,
101- tcp6_announces_handled : http_stats. tcp6_announces_handled ( ) ,
102- tcp6_scrapes_handled : http_stats. tcp6_scrapes_handled ( ) ,
103- // UDP
104- udp_requests_aborted : udp_server_stats. udp_requests_aborted ( ) ,
105- udp_requests_banned : udp_server_stats. udp_requests_banned ( ) ,
106- udp_banned_ips_total : udp_banned_ips_total as u64 ,
107- udp_avg_connect_processing_time_ns : udp_server_stats. udp_avg_connect_processing_time_ns ( ) ,
108- udp_avg_announce_processing_time_ns : udp_server_stats. udp_avg_announce_processing_time_ns ( ) ,
109- udp_avg_scrape_processing_time_ns : udp_server_stats. udp_avg_scrape_processing_time_ns ( ) ,
110- // UDPv4
111- udp4_requests : udp_server_stats. udp4_requests ( ) ,
112- udp4_connections_handled : udp_server_stats. udp4_connections_handled ( ) ,
113- udp4_announces_handled : udp_server_stats. udp4_announces_handled ( ) ,
114- udp4_scrapes_handled : udp_server_stats. udp4_scrapes_handled ( ) ,
115- udp4_responses : udp_server_stats. udp4_responses ( ) ,
116- udp4_errors_handled : udp_server_stats. udp4_errors_handled ( ) ,
117- // UDPv6
118- udp6_requests : udp_server_stats. udp6_requests ( ) ,
119- udp6_connections_handled : udp_server_stats. udp6_connections_handled ( ) ,
120- udp6_announces_handled : udp_server_stats. udp6_announces_handled ( ) ,
121- udp6_scrapes_handled : udp_server_stats. udp6_scrapes_handled ( ) ,
122- udp6_responses : udp_server_stats. udp6_responses ( ) ,
123- udp6_errors_handled : udp_server_stats. udp6_errors_handled ( ) ,
124- }
125- }
126-
12753#[ allow( deprecated) ]
12854#[ allow( clippy:: too_many_lines) ]
129- async fn get_protocol_metrics_from_labeled_metrics (
55+ async fn get_protocol_metrics (
13056 http_stats_repository : Arc < bittorrent_http_tracker_core:: statistics:: repository:: Repository > ,
13157 udp_server_stats_repository : Arc < udp_server_statistics:: repository:: Repository > ,
13258) -> ProtocolMetrics {
@@ -307,7 +233,7 @@ mod tests {
307233 let tracker_core_container =
308234 TrackerCoreContainer :: initialize_from ( & core_config, & swarm_coordination_registry_container. clone ( ) ) ;
309235
310- let ban_service = Arc :: new ( RwLock :: new ( BanService :: new ( MAX_CONNECTION_ID_ERRORS_PER_IP ) ) ) ;
236+ let _ban_service = Arc :: new ( RwLock :: new ( BanService :: new ( MAX_CONNECTION_ID_ERRORS_PER_IP ) ) ) ;
311237
312238 // HTTP core stats
313239 let http_core_broadcaster = Broadcaster :: default ( ) ;
@@ -326,7 +252,6 @@ mod tests {
326252
327253 let tracker_metrics = get_metrics (
328254 tracker_core_container. in_memory_torrent_repository . clone ( ) ,
329- ban_service. clone ( ) ,
330255 tracker_core_container. stats_repository . clone ( ) ,
331256 http_stats_repository. clone ( ) ,
332257 udp_server_stats_repository. clone ( ) ,
0 commit comments