Skip to content

Commit 5f08b2e

Browse files
committedJan 31, 2025··
refactor: [#1228] start using the http tracker stats
Stats have been splited into HTTP and UDP stats. Parallel change, step 1: 1. [x] Start using HTTP Tracker Core Stats 2. [ ] Start using UDP Tracker Core Stats 3. [ ] Get metrics from HTTP and UDP Tracker Core Stats 4. [ ] Remove deprecate unified HTTP and UDP stats.
1 parent 39cbeda commit 5f08b2e

File tree

7 files changed

+306
-69
lines changed

7 files changed

+306
-69
lines changed
 

‎src/container.rs

+2
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ pub struct HttpTrackerContainer {
7171
pub scrape_handler: Arc<ScrapeHandler>,
7272
pub whitelist_authorization: Arc<whitelist::authorization::WhitelistAuthorization>,
7373
pub stats_event_sender: Arc<Option<Box<dyn Sender>>>,
74+
pub http_stats_event_sender: Arc<Option<Box<dyn http_tracker_core::statistics::event::sender::Sender>>>,
7475
pub authentication_service: Arc<AuthenticationService>,
7576
}
7677

@@ -84,6 +85,7 @@ impl HttpTrackerContainer {
8485
scrape_handler: app_container.scrape_handler.clone(),
8586
whitelist_authorization: app_container.whitelist_authorization.clone(),
8687
stats_event_sender: app_container.stats_event_sender.clone(),
88+
http_stats_event_sender: app_container.http_stats_event_sender.clone(),
8789
authentication_service: app_container.authentication_service.clone(),
8890
}
8991
}

‎src/servers/http/v1/handlers/announce.rs

+48-20
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ use torrust_tracker_primitives::core::AnnounceData;
2828
use torrust_tracker_primitives::peer;
2929

3030
use super::common::auth::map_auth_error_to_error_response;
31+
use crate::packages::http_tracker_core;
3132
use crate::servers::http::v1::extractors::announce_request::ExtractRequest;
3233
use crate::servers::http::v1::extractors::authentication_key::Extract as ExtractKey;
3334
use crate::servers::http::v1::extractors::client_ip_sources::Extract as ExtractClientIpSources;
@@ -46,6 +47,7 @@ pub async fn handle_without_key(
4647
Arc<AuthenticationService>,
4748
Arc<whitelist::authorization::WhitelistAuthorization>,
4849
Arc<Option<Box<dyn Sender>>>,
50+
Arc<Option<Box<dyn http_tracker_core::statistics::event::sender::Sender>>>,
4951
)>,
5052
ExtractRequest(announce_request): ExtractRequest,
5153
ExtractClientIpSources(client_ip_sources): ExtractClientIpSources,
@@ -58,6 +60,7 @@ pub async fn handle_without_key(
5860
&state.2,
5961
&state.3,
6062
&state.4,
63+
&state.5,
6164
&announce_request,
6265
&client_ip_sources,
6366
None,
@@ -76,6 +79,7 @@ pub async fn handle_with_key(
7679
Arc<AuthenticationService>,
7780
Arc<whitelist::authorization::WhitelistAuthorization>,
7881
Arc<Option<Box<dyn Sender>>>,
82+
Arc<Option<Box<dyn http_tracker_core::statistics::event::sender::Sender>>>,
7983
)>,
8084
ExtractRequest(announce_request): ExtractRequest,
8185
ExtractClientIpSources(client_ip_sources): ExtractClientIpSources,
@@ -89,6 +93,7 @@ pub async fn handle_with_key(
8993
&state.2,
9094
&state.3,
9195
&state.4,
96+
&state.5,
9297
&announce_request,
9398
&client_ip_sources,
9499
Some(key),
@@ -107,6 +112,7 @@ async fn handle(
107112
authentication_service: &Arc<AuthenticationService>,
108113
whitelist_authorization: &Arc<whitelist::authorization::WhitelistAuthorization>,
109114
opt_stats_event_sender: &Arc<Option<Box<dyn Sender>>>,
115+
opt_http_stats_event_sender: &Arc<Option<Box<dyn http_tracker_core::statistics::event::sender::Sender>>>,
110116
announce_request: &Announce,
111117
client_ip_sources: &ClientIpSources,
112118
maybe_key: Option<Key>,
@@ -117,6 +123,7 @@ async fn handle(
117123
authentication_service,
118124
whitelist_authorization,
119125
opt_stats_event_sender,
126+
opt_http_stats_event_sender,
120127
announce_request,
121128
client_ip_sources,
122129
maybe_key,
@@ -142,6 +149,7 @@ async fn handle_announce(
142149
authentication_service: &Arc<AuthenticationService>,
143150
whitelist_authorization: &Arc<whitelist::authorization::WhitelistAuthorization>,
144151
opt_stats_event_sender: &Arc<Option<Box<dyn Sender>>>,
152+
opt_http_stats_event_sender: &Arc<Option<Box<dyn http_tracker_core::statistics::event::sender::Sender>>>,
145153
announce_request: &Announce,
146154
client_ip_sources: &ClientIpSources,
147155
maybe_key: Option<Key>,
@@ -181,6 +189,7 @@ async fn handle_announce(
181189
let announce_data = services::announce::invoke(
182190
announce_handler.clone(),
183191
opt_stats_event_sender.clone(),
192+
opt_http_stats_event_sender.clone(),
184193
announce_request.info_hash,
185194
&mut peer,
186195
&peers_wanted,
@@ -265,7 +274,7 @@ mod tests {
265274
use torrust_tracker_configuration::{Configuration, Core};
266275
use torrust_tracker_test_helpers::configuration;
267276

268-
use crate::packages;
277+
use crate::packages::{self, http_tracker_core};
269278

270279
struct CoreTrackerServices {
271280
pub core_config: Arc<Core>,
@@ -275,23 +284,27 @@ mod tests {
275284
pub authentication_service: Arc<AuthenticationService>,
276285
}
277286

278-
fn initialize_private_tracker() -> CoreTrackerServices {
287+
struct CoreHttpTrackerServices {
288+
pub http_stats_event_sender: Arc<Option<Box<dyn http_tracker_core::statistics::event::sender::Sender>>>,
289+
}
290+
291+
fn initialize_private_tracker() -> (CoreTrackerServices, CoreHttpTrackerServices) {
279292
initialize_core_tracker_services(&configuration::ephemeral_private())
280293
}
281294

282-
fn initialize_listed_tracker() -> CoreTrackerServices {
295+
fn initialize_listed_tracker() -> (CoreTrackerServices, CoreHttpTrackerServices) {
283296
initialize_core_tracker_services(&configuration::ephemeral_listed())
284297
}
285298

286-
fn initialize_tracker_on_reverse_proxy() -> CoreTrackerServices {
299+
fn initialize_tracker_on_reverse_proxy() -> (CoreTrackerServices, CoreHttpTrackerServices) {
287300
initialize_core_tracker_services(&configuration::ephemeral_with_reverse_proxy())
288301
}
289302

290-
fn initialize_tracker_not_on_reverse_proxy() -> CoreTrackerServices {
303+
fn initialize_tracker_not_on_reverse_proxy() -> (CoreTrackerServices, CoreHttpTrackerServices) {
291304
initialize_core_tracker_services(&configuration::ephemeral_without_reverse_proxy())
292305
}
293306

294-
fn initialize_core_tracker_services(config: &Configuration) -> CoreTrackerServices {
307+
fn initialize_core_tracker_services(config: &Configuration) -> (CoreTrackerServices, CoreHttpTrackerServices) {
295308
let core_config = Arc::new(config.core.clone());
296309
let database = initialize_database(config);
297310
let in_memory_whitelist = Arc::new(InMemoryWhitelist::default());
@@ -300,21 +313,31 @@ mod tests {
300313
let authentication_service = Arc::new(AuthenticationService::new(&config.core, &in_memory_key_repository));
301314
let in_memory_torrent_repository = Arc::new(InMemoryTorrentRepository::default());
302315
let db_torrent_repository = Arc::new(DatabasePersistentTorrentRepository::new(&database));
303-
let (stats_event_sender, _stats_repository) = statistics::setup::factory(config.core.tracker_usage_statistics);
304-
let stats_event_sender = Arc::new(stats_event_sender);
305316
let announce_handler = Arc::new(AnnounceHandler::new(
306317
&config.core,
307318
&in_memory_torrent_repository,
308319
&db_torrent_repository,
309320
));
310321

311-
CoreTrackerServices {
312-
core_config,
313-
announce_handler,
314-
stats_event_sender,
315-
whitelist_authorization,
316-
authentication_service,
317-
}
322+
let (stats_event_sender, _stats_repository) = statistics::setup::factory(config.core.tracker_usage_statistics);
323+
let stats_event_sender = Arc::new(stats_event_sender);
324+
325+
// HTTP stats
326+
let (http_stats_event_sender, http_stats_repository) =
327+
http_tracker_core::statistics::setup::factory(config.core.tracker_usage_statistics);
328+
let http_stats_event_sender = Arc::new(http_stats_event_sender);
329+
let _http_stats_repository = Arc::new(http_stats_repository);
330+
331+
(
332+
CoreTrackerServices {
333+
core_config,
334+
announce_handler,
335+
stats_event_sender,
336+
whitelist_authorization,
337+
authentication_service,
338+
},
339+
CoreHttpTrackerServices { http_stats_event_sender },
340+
)
318341
}
319342

320343
fn sample_announce_request() -> Announce {
@@ -357,7 +380,7 @@ mod tests {
357380

358381
#[tokio::test]
359382
async fn it_should_fail_when_the_authentication_key_is_missing() {
360-
let core_tracker_services = initialize_private_tracker();
383+
let (core_tracker_services, http_core_tracker_services) = initialize_private_tracker();
361384

362385
let maybe_key = None;
363386

@@ -367,6 +390,7 @@ mod tests {
367390
&core_tracker_services.authentication_service,
368391
&core_tracker_services.whitelist_authorization,
369392
&core_tracker_services.stats_event_sender,
393+
&http_core_tracker_services.http_stats_event_sender,
370394
&sample_announce_request(),
371395
&sample_client_ip_sources(),
372396
maybe_key,
@@ -382,7 +406,7 @@ mod tests {
382406

383407
#[tokio::test]
384408
async fn it_should_fail_when_the_authentication_key_is_invalid() {
385-
let core_tracker_services = initialize_private_tracker();
409+
let (core_tracker_services, http_core_tracker_services) = initialize_private_tracker();
386410

387411
let unregistered_key = authentication::Key::from_str("YZSl4lMZupRuOpSRC3krIKR5BPB14nrJ").unwrap();
388412

@@ -394,6 +418,7 @@ mod tests {
394418
&core_tracker_services.authentication_service,
395419
&core_tracker_services.whitelist_authorization,
396420
&core_tracker_services.stats_event_sender,
421+
&http_core_tracker_services.http_stats_event_sender,
397422
&sample_announce_request(),
398423
&sample_client_ip_sources(),
399424
maybe_key,
@@ -413,7 +438,7 @@ mod tests {
413438

414439
#[tokio::test]
415440
async fn it_should_fail_when_the_announced_torrent_is_not_whitelisted() {
416-
let core_tracker_services = initialize_listed_tracker();
441+
let (core_tracker_services, http_core_tracker_services) = initialize_listed_tracker();
417442

418443
let announce_request = sample_announce_request();
419444

@@ -423,6 +448,7 @@ mod tests {
423448
&core_tracker_services.authentication_service,
424449
&core_tracker_services.whitelist_authorization,
425450
&core_tracker_services.stats_event_sender,
451+
&http_core_tracker_services.http_stats_event_sender,
426452
&announce_request,
427453
&sample_client_ip_sources(),
428454
None,
@@ -450,7 +476,7 @@ mod tests {
450476

451477
#[tokio::test]
452478
async fn it_should_fail_when_the_right_most_x_forwarded_for_header_ip_is_not_available() {
453-
let core_tracker_services = initialize_tracker_on_reverse_proxy();
479+
let (core_tracker_services, http_core_tracker_services) = initialize_tracker_on_reverse_proxy();
454480

455481
let client_ip_sources = ClientIpSources {
456482
right_most_x_forwarded_for: None,
@@ -463,6 +489,7 @@ mod tests {
463489
&core_tracker_services.authentication_service,
464490
&core_tracker_services.whitelist_authorization,
465491
&core_tracker_services.stats_event_sender,
492+
&http_core_tracker_services.http_stats_event_sender,
466493
&sample_announce_request(),
467494
&client_ip_sources,
468495
None,
@@ -487,7 +514,7 @@ mod tests {
487514

488515
#[tokio::test]
489516
async fn it_should_fail_when_the_client_ip_from_the_connection_info_is_not_available() {
490-
let core_tracker_services = initialize_tracker_not_on_reverse_proxy();
517+
let (core_tracker_services, http_core_tracker_services) = initialize_tracker_not_on_reverse_proxy();
491518

492519
let client_ip_sources = ClientIpSources {
493520
right_most_x_forwarded_for: None,
@@ -500,6 +527,7 @@ mod tests {
500527
&core_tracker_services.authentication_service,
501528
&core_tracker_services.whitelist_authorization,
502529
&core_tracker_services.stats_event_sender,
530+
&http_core_tracker_services.http_stats_event_sender,
503531
&sample_announce_request(),
504532
&client_ip_sources,
505533
None,

‎src/servers/http/v1/handlers/scrape.rs

+59-21
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ use packages::statistics::event::sender::Sender;
2020
use torrust_tracker_configuration::Core;
2121
use torrust_tracker_primitives::core::ScrapeData;
2222

23-
use crate::packages;
23+
use crate::packages::{self, http_tracker_core};
2424
use crate::servers::http::v1::extractors::authentication_key::Extract as ExtractKey;
2525
use crate::servers::http::v1::extractors::client_ip_sources::Extract as ExtractClientIpSources;
2626
use crate::servers::http::v1::extractors::scrape_request::ExtractRequest;
@@ -36,6 +36,7 @@ pub async fn handle_without_key(
3636
Arc<ScrapeHandler>,
3737
Arc<AuthenticationService>,
3838
Arc<Option<Box<dyn Sender>>>,
39+
Arc<Option<Box<dyn http_tracker_core::statistics::event::sender::Sender>>>,
3940
)>,
4041
ExtractRequest(scrape_request): ExtractRequest,
4142
ExtractClientIpSources(client_ip_sources): ExtractClientIpSources,
@@ -47,6 +48,7 @@ pub async fn handle_without_key(
4748
&state.1,
4849
&state.2,
4950
&state.3,
51+
&state.4,
5052
&scrape_request,
5153
&client_ip_sources,
5254
None,
@@ -66,6 +68,7 @@ pub async fn handle_with_key(
6668
Arc<ScrapeHandler>,
6769
Arc<AuthenticationService>,
6870
Arc<Option<Box<dyn Sender>>>,
71+
Arc<Option<Box<dyn http_tracker_core::statistics::event::sender::Sender>>>,
6972
)>,
7073
ExtractRequest(scrape_request): ExtractRequest,
7174
ExtractClientIpSources(client_ip_sources): ExtractClientIpSources,
@@ -78,6 +81,7 @@ pub async fn handle_with_key(
7881
&state.1,
7982
&state.2,
8083
&state.3,
84+
&state.4,
8185
&scrape_request,
8286
&client_ip_sources,
8387
Some(key),
@@ -91,6 +95,7 @@ async fn handle(
9195
scrape_handler: &Arc<ScrapeHandler>,
9296
authentication_service: &Arc<AuthenticationService>,
9397
stats_event_sender: &Arc<Option<Box<dyn Sender>>>,
98+
http_stats_event_sender: &Arc<Option<Box<dyn http_tracker_core::statistics::event::sender::Sender>>>,
9499
scrape_request: &Scrape,
95100
client_ip_sources: &ClientIpSources,
96101
maybe_key: Option<Key>,
@@ -100,6 +105,7 @@ async fn handle(
100105
scrape_handler,
101106
authentication_service,
102107
stats_event_sender,
108+
http_stats_event_sender,
103109
scrape_request,
104110
client_ip_sources,
105111
maybe_key,
@@ -124,6 +130,7 @@ async fn handle_scrape(
124130
scrape_handler: &Arc<ScrapeHandler>,
125131
authentication_service: &Arc<AuthenticationService>,
126132
opt_stats_event_sender: &Arc<Option<Box<dyn Sender>>>,
133+
opt_http_stats_event_sender: &Arc<Option<Box<dyn http_tracker_core::statistics::event::sender::Sender>>>,
127134
scrape_request: &Scrape,
128135
client_ip_sources: &ClientIpSources,
129136
maybe_key: Option<Key>,
@@ -150,9 +157,22 @@ async fn handle_scrape(
150157
};
151158

152159
if return_real_scrape_data {
153-
Ok(services::scrape::invoke(scrape_handler, opt_stats_event_sender, &scrape_request.info_hashes, &peer_ip).await)
160+
Ok(services::scrape::invoke(
161+
scrape_handler,
162+
opt_stats_event_sender,
163+
opt_http_stats_event_sender,
164+
&scrape_request.info_hashes,
165+
&peer_ip,
166+
)
167+
.await)
154168
} else {
155-
Ok(services::scrape::fake(opt_stats_event_sender, &scrape_request.info_hashes, &peer_ip).await)
169+
Ok(services::scrape::fake(
170+
opt_stats_event_sender,
171+
opt_http_stats_event_sender,
172+
&scrape_request.info_hashes,
173+
&peer_ip,
174+
)
175+
.await)
156176
}
157177
}
158178

@@ -182,7 +202,7 @@ mod tests {
182202
use torrust_tracker_configuration::{Configuration, Core};
183203
use torrust_tracker_test_helpers::configuration;
184204

185-
use crate::packages;
205+
use crate::packages::{self, http_tracker_core};
186206

187207
struct CoreTrackerServices {
188208
pub core_config: Arc<Core>,
@@ -191,39 +211,52 @@ mod tests {
191211
pub authentication_service: Arc<AuthenticationService>,
192212
}
193213

194-
fn initialize_private_tracker() -> CoreTrackerServices {
214+
struct CoreHttpTrackerServices {
215+
pub http_stats_event_sender: Arc<Option<Box<dyn http_tracker_core::statistics::event::sender::Sender>>>,
216+
}
217+
218+
fn initialize_private_tracker() -> (CoreTrackerServices, CoreHttpTrackerServices) {
195219
initialize_core_tracker_services(&configuration::ephemeral_private())
196220
}
197221

198-
fn initialize_listed_tracker() -> CoreTrackerServices {
222+
fn initialize_listed_tracker() -> (CoreTrackerServices, CoreHttpTrackerServices) {
199223
initialize_core_tracker_services(&configuration::ephemeral_listed())
200224
}
201225

202-
fn initialize_tracker_on_reverse_proxy() -> CoreTrackerServices {
226+
fn initialize_tracker_on_reverse_proxy() -> (CoreTrackerServices, CoreHttpTrackerServices) {
203227
initialize_core_tracker_services(&configuration::ephemeral_with_reverse_proxy())
204228
}
205229

206-
fn initialize_tracker_not_on_reverse_proxy() -> CoreTrackerServices {
230+
fn initialize_tracker_not_on_reverse_proxy() -> (CoreTrackerServices, CoreHttpTrackerServices) {
207231
initialize_core_tracker_services(&configuration::ephemeral_without_reverse_proxy())
208232
}
209233

210-
fn initialize_core_tracker_services(config: &Configuration) -> CoreTrackerServices {
234+
fn initialize_core_tracker_services(config: &Configuration) -> (CoreTrackerServices, CoreHttpTrackerServices) {
211235
let core_config = Arc::new(config.core.clone());
212236
let in_memory_whitelist = Arc::new(InMemoryWhitelist::default());
213237
let whitelist_authorization = Arc::new(WhitelistAuthorization::new(&config.core, &in_memory_whitelist.clone()));
214238
let in_memory_key_repository = Arc::new(InMemoryKeyRepository::default());
215239
let authentication_service = Arc::new(AuthenticationService::new(&config.core, &in_memory_key_repository));
216240
let in_memory_torrent_repository = Arc::new(InMemoryTorrentRepository::default());
241+
let scrape_handler = Arc::new(ScrapeHandler::new(&whitelist_authorization, &in_memory_torrent_repository));
242+
217243
let (stats_event_sender, _stats_repository) = statistics::setup::factory(config.core.tracker_usage_statistics);
218244
let stats_event_sender = Arc::new(stats_event_sender);
219-
let scrape_handler = Arc::new(ScrapeHandler::new(&whitelist_authorization, &in_memory_torrent_repository));
220245

221-
CoreTrackerServices {
222-
core_config,
223-
scrape_handler,
224-
stats_event_sender,
225-
authentication_service,
226-
}
246+
// HTTP stats
247+
let (http_stats_event_sender, _http_stats_repository) =
248+
http_tracker_core::statistics::setup::factory(config.core.tracker_usage_statistics);
249+
let http_stats_event_sender = Arc::new(http_stats_event_sender);
250+
251+
(
252+
CoreTrackerServices {
253+
core_config,
254+
scrape_handler,
255+
stats_event_sender,
256+
authentication_service,
257+
},
258+
CoreHttpTrackerServices { http_stats_event_sender },
259+
)
227260
}
228261

229262
fn sample_scrape_request() -> Scrape {
@@ -257,7 +290,7 @@ mod tests {
257290

258291
#[tokio::test]
259292
async fn it_should_return_zeroed_swarm_metadata_when_the_authentication_key_is_missing() {
260-
let core_tracker_services = initialize_private_tracker();
293+
let (core_tracker_services, core_http_tracker_services) = initialize_private_tracker();
261294

262295
let scrape_request = sample_scrape_request();
263296
let maybe_key = None;
@@ -267,6 +300,7 @@ mod tests {
267300
&core_tracker_services.scrape_handler,
268301
&core_tracker_services.authentication_service,
269302
&core_tracker_services.stats_event_sender,
303+
&core_http_tracker_services.http_stats_event_sender,
270304
&scrape_request,
271305
&sample_client_ip_sources(),
272306
maybe_key,
@@ -281,7 +315,7 @@ mod tests {
281315

282316
#[tokio::test]
283317
async fn it_should_return_zeroed_swarm_metadata_when_the_authentication_key_is_invalid() {
284-
let core_tracker_services = initialize_private_tracker();
318+
let (core_tracker_services, core_http_tracker_services) = initialize_private_tracker();
285319

286320
let scrape_request = sample_scrape_request();
287321
let unregistered_key = authentication::Key::from_str("YZSl4lMZupRuOpSRC3krIKR5BPB14nrJ").unwrap();
@@ -292,6 +326,7 @@ mod tests {
292326
&core_tracker_services.scrape_handler,
293327
&core_tracker_services.authentication_service,
294328
&core_tracker_services.stats_event_sender,
329+
&core_http_tracker_services.http_stats_event_sender,
295330
&scrape_request,
296331
&sample_client_ip_sources(),
297332
maybe_key,
@@ -314,7 +349,7 @@ mod tests {
314349

315350
#[tokio::test]
316351
async fn it_should_return_zeroed_swarm_metadata_when_the_torrent_is_not_whitelisted() {
317-
let core_tracker_services = initialize_listed_tracker();
352+
let (core_tracker_services, core_http_tracker_services) = initialize_listed_tracker();
318353

319354
let scrape_request = sample_scrape_request();
320355

@@ -323,6 +358,7 @@ mod tests {
323358
&core_tracker_services.scrape_handler,
324359
&core_tracker_services.authentication_service,
325360
&core_tracker_services.stats_event_sender,
361+
&core_http_tracker_services.http_stats_event_sender,
326362
&scrape_request,
327363
&sample_client_ip_sources(),
328364
None,
@@ -346,7 +382,7 @@ mod tests {
346382

347383
#[tokio::test]
348384
async fn it_should_fail_when_the_right_most_x_forwarded_for_header_ip_is_not_available() {
349-
let core_tracker_services = initialize_tracker_on_reverse_proxy();
385+
let (core_tracker_services, core_http_tracker_services) = initialize_tracker_on_reverse_proxy();
350386

351387
let client_ip_sources = ClientIpSources {
352388
right_most_x_forwarded_for: None,
@@ -358,6 +394,7 @@ mod tests {
358394
&core_tracker_services.scrape_handler,
359395
&core_tracker_services.authentication_service,
360396
&core_tracker_services.stats_event_sender,
397+
&core_http_tracker_services.http_stats_event_sender,
361398
&sample_scrape_request(),
362399
&client_ip_sources,
363400
None,
@@ -382,7 +419,7 @@ mod tests {
382419

383420
#[tokio::test]
384421
async fn it_should_fail_when_the_client_ip_from_the_connection_info_is_not_available() {
385-
let core_tracker_services = initialize_tracker_not_on_reverse_proxy();
422+
let (core_tracker_services, core_http_tracker_services) = initialize_tracker_not_on_reverse_proxy();
386423

387424
let client_ip_sources = ClientIpSources {
388425
right_most_x_forwarded_for: None,
@@ -394,6 +431,7 @@ mod tests {
394431
&core_tracker_services.scrape_handler,
395432
&core_tracker_services.authentication_service,
396433
&core_tracker_services.stats_event_sender,
434+
&core_http_tracker_services.http_stats_event_sender,
397435
&sample_scrape_request(),
398436
&client_ip_sources,
399437
None,

‎src/servers/http/v1/routes.rs

+4
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ pub fn router(http_tracker_container: Arc<HttpTrackerContainer>, server_socket_a
4444
http_tracker_container.authentication_service.clone(),
4545
http_tracker_container.whitelist_authorization.clone(),
4646
http_tracker_container.stats_event_sender.clone(),
47+
http_tracker_container.http_stats_event_sender.clone(),
4748
)),
4849
)
4950
.route(
@@ -54,6 +55,7 @@ pub fn router(http_tracker_container: Arc<HttpTrackerContainer>, server_socket_a
5455
http_tracker_container.authentication_service.clone(),
5556
http_tracker_container.whitelist_authorization.clone(),
5657
http_tracker_container.stats_event_sender.clone(),
58+
http_tracker_container.http_stats_event_sender.clone(),
5759
)),
5860
)
5961
// Scrape request
@@ -64,6 +66,7 @@ pub fn router(http_tracker_container: Arc<HttpTrackerContainer>, server_socket_a
6466
http_tracker_container.scrape_handler.clone(),
6567
http_tracker_container.authentication_service.clone(),
6668
http_tracker_container.stats_event_sender.clone(),
69+
http_tracker_container.http_stats_event_sender.clone(),
6770
)),
6871
)
6972
.route(
@@ -73,6 +76,7 @@ pub fn router(http_tracker_container: Arc<HttpTrackerContainer>, server_socket_a
7376
http_tracker_container.scrape_handler.clone(),
7477
http_tracker_container.authentication_service.clone(),
7578
http_tracker_container.stats_event_sender.clone(),
79+
http_tracker_container.http_stats_event_sender.clone(),
7680
)),
7781
)
7882
// Add extension to get the client IP from the connection info

‎src/servers/http/v1/services/announce.rs

+84-13
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use packages::statistics::event::sender::Sender;
1717
use torrust_tracker_primitives::core::AnnounceData;
1818
use torrust_tracker_primitives::peer;
1919

20-
use crate::packages;
20+
use crate::packages::{self, http_tracker_core};
2121

2222
/// The HTTP tracker `announce` service.
2323
///
@@ -32,6 +32,7 @@ use crate::packages;
3232
pub async fn invoke(
3333
announce_handler: Arc<AnnounceHandler>,
3434
opt_stats_event_sender: Arc<Option<Box<dyn Sender>>>,
35+
opt_http_stats_event_sender: Arc<Option<Box<dyn http_tracker_core::statistics::event::sender::Sender>>>,
3536
info_hash: InfoHash,
3637
peer: &mut peer::Peer,
3738
peers_wanted: &PeersWanted,
@@ -52,6 +53,21 @@ pub async fn invoke(
5253
}
5354
}
5455

56+
if let Some(http_stats_event_sender) = opt_http_stats_event_sender.as_deref() {
57+
match original_peer_ip {
58+
IpAddr::V4(_) => {
59+
http_stats_event_sender
60+
.send_event(http_tracker_core::statistics::event::Event::Tcp4Announce)
61+
.await;
62+
}
63+
IpAddr::V6(_) => {
64+
http_stats_event_sender
65+
.send_event(http_tracker_core::statistics::event::Event::Tcp6Announce)
66+
.await;
67+
}
68+
}
69+
}
70+
5571
announce_data
5672
}
5773

@@ -77,26 +93,41 @@ mod tests {
7793
pub stats_event_sender: Arc<Option<Box<dyn Sender>>>,
7894
}
7995

80-
fn initialize_core_tracker_services() -> CoreTrackerServices {
96+
struct CoreHttpTrackerServices {
97+
pub http_stats_event_sender: Arc<Option<Box<dyn http_tracker_core::statistics::event::sender::Sender>>>,
98+
}
99+
100+
fn initialize_core_tracker_services() -> (CoreTrackerServices, CoreHttpTrackerServices) {
81101
let config = configuration::ephemeral_public();
82102

83103
let core_config = Arc::new(config.core.clone());
84104
let database = initialize_database(&config);
85105
let in_memory_torrent_repository = Arc::new(InMemoryTorrentRepository::default());
86106
let db_torrent_repository = Arc::new(DatabasePersistentTorrentRepository::new(&database));
87-
let (stats_event_sender, _stats_repository) = statistics::setup::factory(config.core.tracker_usage_statistics);
88-
let stats_event_sender = Arc::new(stats_event_sender);
107+
89108
let announce_handler = Arc::new(AnnounceHandler::new(
90109
&config.core,
91110
&in_memory_torrent_repository,
92111
&db_torrent_repository,
93112
));
94113

95-
CoreTrackerServices {
96-
core_config,
97-
announce_handler,
98-
stats_event_sender,
99-
}
114+
let (stats_event_sender, _stats_repository) = statistics::setup::factory(config.core.tracker_usage_statistics);
115+
let stats_event_sender = Arc::new(stats_event_sender);
116+
117+
// HTTP stats
118+
let (http_stats_event_sender, http_stats_repository) =
119+
http_tracker_core::statistics::setup::factory(config.core.tracker_usage_statistics);
120+
let http_stats_event_sender = Arc::new(http_stats_event_sender);
121+
let _http_stats_repository = Arc::new(http_stats_repository);
122+
123+
(
124+
CoreTrackerServices {
125+
core_config,
126+
announce_handler,
127+
stats_event_sender,
128+
},
129+
CoreHttpTrackerServices { http_stats_event_sender },
130+
)
100131
}
101132

102133
fn sample_peer_using_ipv4() -> peer::Peer {
@@ -129,7 +160,7 @@ mod tests {
129160
use packages::statistics::event::Event;
130161
use tokio::sync::mpsc::error::SendError;
131162

132-
use crate::packages;
163+
use crate::packages::{self, http_tracker_core};
133164

134165
mock! {
135166
StatsEventSender {}
@@ -138,6 +169,13 @@ mod tests {
138169
}
139170
}
140171

172+
mock! {
173+
HttpStatsEventSender {}
174+
impl http_tracker_core::statistics::event::sender::Sender for HttpStatsEventSender {
175+
fn send_event(&self, event: http_tracker_core::statistics::event::Event) -> BoxFuture<'static,Option<Result<(),SendError<http_tracker_core::statistics::event::Event> > > > ;
176+
}
177+
}
178+
141179
mod with_tracker_in_any_mode {
142180
use std::future;
143181
use std::net::{IpAddr, Ipv4Addr, Ipv6Addr, SocketAddr};
@@ -156,10 +194,10 @@ mod tests {
156194
use torrust_tracker_test_helpers::configuration;
157195

158196
use super::{sample_peer_using_ipv4, sample_peer_using_ipv6};
159-
use crate::packages;
197+
use crate::packages::{self, http_tracker_core};
160198
use crate::servers::http::v1::services::announce::invoke;
161199
use crate::servers::http::v1::services::announce::tests::{
162-
initialize_core_tracker_services, sample_peer, MockStatsEventSender,
200+
initialize_core_tracker_services, sample_peer, MockHttpStatsEventSender, MockStatsEventSender,
163201
};
164202

165203
fn initialize_announce_handler() -> Arc<AnnounceHandler> {
@@ -178,13 +216,14 @@ mod tests {
178216

179217
#[tokio::test]
180218
async fn it_should_return_the_announce_data() {
181-
let core_tracker_services = initialize_core_tracker_services();
219+
let (core_tracker_services, core_http_tracker_services) = initialize_core_tracker_services();
182220

183221
let mut peer = sample_peer();
184222

185223
let announce_data = invoke(
186224
core_tracker_services.announce_handler.clone(),
187225
core_tracker_services.stats_event_sender.clone(),
226+
core_http_tracker_services.http_stats_event_sender.clone(),
188227
sample_info_hash(),
189228
&mut peer,
190229
&PeersWanted::All,
@@ -215,13 +254,23 @@ mod tests {
215254
let stats_event_sender: Arc<Option<Box<dyn statistics::event::sender::Sender>>> =
216255
Arc::new(Some(Box::new(stats_event_sender_mock)));
217256

257+
let mut http_stats_event_sender_mock = MockHttpStatsEventSender::new();
258+
http_stats_event_sender_mock
259+
.expect_send_event()
260+
.with(eq(http_tracker_core::statistics::event::Event::Tcp4Announce))
261+
.times(1)
262+
.returning(|_| Box::pin(future::ready(Some(Ok(())))));
263+
let http_stats_event_sender: Arc<Option<Box<dyn http_tracker_core::statistics::event::sender::Sender>>> =
264+
Arc::new(Some(Box::new(http_stats_event_sender_mock)));
265+
218266
let announce_handler = initialize_announce_handler();
219267

220268
let mut peer = sample_peer_using_ipv4();
221269

222270
let _announce_data = invoke(
223271
announce_handler,
224272
stats_event_sender,
273+
http_stats_event_sender,
225274
sample_info_hash(),
226275
&mut peer,
227276
&PeersWanted::All,
@@ -260,13 +309,24 @@ mod tests {
260309
let stats_event_sender: Arc<Option<Box<dyn statistics::event::sender::Sender>>> =
261310
Arc::new(Some(Box::new(stats_event_sender_mock)));
262311

312+
// Assert that the event sent is a TCP4 event
313+
let mut http_stats_event_sender_mock = MockHttpStatsEventSender::new();
314+
http_stats_event_sender_mock
315+
.expect_send_event()
316+
.with(eq(http_tracker_core::statistics::event::Event::Tcp4Announce))
317+
.times(1)
318+
.returning(|_| Box::pin(future::ready(Some(Ok(())))));
319+
let http_stats_event_sender: Arc<Option<Box<dyn http_tracker_core::statistics::event::sender::Sender>>> =
320+
Arc::new(Some(Box::new(http_stats_event_sender_mock)));
321+
263322
let mut peer = peer_with_the_ipv4_loopback_ip();
264323

265324
let announce_handler = tracker_with_an_ipv6_external_ip();
266325

267326
let _announce_data = invoke(
268327
announce_handler,
269328
stats_event_sender,
329+
http_stats_event_sender,
270330
sample_info_hash(),
271331
&mut peer,
272332
&PeersWanted::All,
@@ -286,13 +346,24 @@ mod tests {
286346
let stats_event_sender: Arc<Option<Box<dyn statistics::event::sender::Sender>>> =
287347
Arc::new(Some(Box::new(stats_event_sender_mock)));
288348

349+
// Assert that the event sent is a TCP4 event
350+
let mut http_stats_event_sender_mock = MockHttpStatsEventSender::new();
351+
http_stats_event_sender_mock
352+
.expect_send_event()
353+
.with(eq(http_tracker_core::statistics::event::Event::Tcp6Announce))
354+
.times(1)
355+
.returning(|_| Box::pin(future::ready(Some(Ok(())))));
356+
let http_stats_event_sender: Arc<Option<Box<dyn http_tracker_core::statistics::event::sender::Sender>>> =
357+
Arc::new(Some(Box::new(http_stats_event_sender_mock)));
358+
289359
let announce_handler = initialize_announce_handler();
290360

291361
let mut peer = sample_peer_using_ipv6();
292362

293363
let _announce_data = invoke(
294364
announce_handler,
295365
stats_event_sender,
366+
http_stats_event_sender,
296367
sample_info_hash(),
297368
&mut peer,
298369
&PeersWanted::All,

‎src/servers/http/v1/services/scrape.rs

+108-15
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use packages::statistics::event::sender::Sender;
1616
use packages::statistics::{self};
1717
use torrust_tracker_primitives::core::ScrapeData;
1818

19-
use crate::packages;
19+
use crate::packages::{self, http_tracker_core};
2020

2121
/// The HTTP tracker `scrape` service.
2222
///
@@ -31,12 +31,13 @@ use crate::packages;
3131
pub async fn invoke(
3232
scrape_handler: &Arc<ScrapeHandler>,
3333
opt_stats_event_sender: &Arc<Option<Box<dyn Sender>>>,
34+
opt_http_stats_event_sender: &Arc<Option<Box<dyn http_tracker_core::statistics::event::sender::Sender>>>,
3435
info_hashes: &Vec<InfoHash>,
3536
original_peer_ip: &IpAddr,
3637
) -> ScrapeData {
3738
let scrape_data = scrape_handler.scrape(info_hashes).await;
3839

39-
send_scrape_event(original_peer_ip, opt_stats_event_sender).await;
40+
send_scrape_event(original_peer_ip, opt_stats_event_sender, opt_http_stats_event_sender).await;
4041

4142
scrape_data
4243
}
@@ -49,15 +50,20 @@ pub async fn invoke(
4950
/// > **NOTICE**: tracker statistics are not updated in this case.
5051
pub async fn fake(
5152
opt_stats_event_sender: &Arc<Option<Box<dyn Sender>>>,
53+
opt_http_stats_event_sender: &Arc<Option<Box<dyn http_tracker_core::statistics::event::sender::Sender>>>,
5254
info_hashes: &Vec<InfoHash>,
5355
original_peer_ip: &IpAddr,
5456
) -> ScrapeData {
55-
send_scrape_event(original_peer_ip, opt_stats_event_sender).await;
57+
send_scrape_event(original_peer_ip, opt_stats_event_sender, opt_http_stats_event_sender).await;
5658

5759
ScrapeData::zeroed(info_hashes)
5860
}
5961

60-
async fn send_scrape_event(original_peer_ip: &IpAddr, opt_stats_event_sender: &Arc<Option<Box<dyn Sender>>>) {
62+
async fn send_scrape_event(
63+
original_peer_ip: &IpAddr,
64+
opt_stats_event_sender: &Arc<Option<Box<dyn Sender>>>,
65+
opt_http_stats_event_sender: &Arc<Option<Box<dyn http_tracker_core::statistics::event::sender::Sender>>>,
66+
) {
6167
if let Some(stats_event_sender) = opt_stats_event_sender.as_deref() {
6268
match original_peer_ip {
6369
IpAddr::V4(_) => {
@@ -68,6 +74,21 @@ async fn send_scrape_event(original_peer_ip: &IpAddr, opt_stats_event_sender: &A
6874
}
6975
}
7076
}
77+
78+
if let Some(http_stats_event_sender) = opt_http_stats_event_sender.as_deref() {
79+
match original_peer_ip {
80+
IpAddr::V4(_) => {
81+
http_stats_event_sender
82+
.send_event(http_tracker_core::statistics::event::Event::Tcp4Scrape)
83+
.await;
84+
}
85+
IpAddr::V6(_) => {
86+
http_stats_event_sender
87+
.send_event(http_tracker_core::statistics::event::Event::Tcp6Scrape)
88+
.await;
89+
}
90+
}
91+
}
7192
}
7293

7394
#[cfg(test)]
@@ -94,7 +115,7 @@ mod tests {
94115
use torrust_tracker_primitives::{peer, DurationSinceUnixEpoch};
95116
use torrust_tracker_test_helpers::configuration;
96117

97-
use crate::packages;
118+
use crate::packages::{self, http_tracker_core};
98119

99120
fn initialize_announce_and_scrape_handlers_for_public_tracker() -> (Arc<AnnounceHandler>, Arc<ScrapeHandler>) {
100121
let config = configuration::ephemeral_public();
@@ -147,6 +168,13 @@ mod tests {
147168
}
148169
}
149170

171+
mock! {
172+
HttpStatsEventSender {}
173+
impl http_tracker_core::statistics::event::sender::Sender for HttpStatsEventSender {
174+
fn send_event(&self, event: http_tracker_core::statistics::event::Event) -> BoxFuture<'static,Option<Result<(),SendError<http_tracker_core::statistics::event::Event> > > > ;
175+
}
176+
}
177+
150178
mod with_real_data {
151179

152180
use std::future;
@@ -159,18 +187,22 @@ mod tests {
159187
use torrust_tracker_primitives::core::ScrapeData;
160188
use torrust_tracker_primitives::swarm_metadata::SwarmMetadata;
161189

162-
use crate::packages;
190+
use crate::packages::{self, http_tracker_core};
163191
use crate::servers::http::v1::services::scrape::invoke;
164192
use crate::servers::http::v1::services::scrape::tests::{
165193
initialize_announce_and_scrape_handlers_for_public_tracker, initialize_scrape_handler, sample_info_hash,
166-
sample_info_hashes, sample_peer, MockStatsEventSender,
194+
sample_info_hashes, sample_peer, MockHttpStatsEventSender, MockStatsEventSender,
167195
};
168196

169197
#[tokio::test]
170198
async fn it_should_return_the_scrape_data_for_a_torrent() {
171199
let (stats_event_sender, _stats_repository) = packages::statistics::setup::factory(false);
172200
let stats_event_sender = Arc::new(stats_event_sender);
173201

202+
let (http_stats_event_sender, _http_stats_repository) =
203+
packages::http_tracker_core::statistics::setup::factory(false);
204+
let http_stats_event_sender = Arc::new(http_stats_event_sender);
205+
174206
let (announce_handler, scrape_handler) = initialize_announce_and_scrape_handlers_for_public_tracker();
175207

176208
let info_hash = sample_info_hash();
@@ -181,7 +213,14 @@ mod tests {
181213
let original_peer_ip = peer.ip();
182214
announce_handler.announce(&info_hash, &mut peer, &original_peer_ip, &PeersWanted::All);
183215

184-
let scrape_data = invoke(&scrape_handler, &stats_event_sender, &info_hashes, &original_peer_ip).await;
216+
let scrape_data = invoke(
217+
&scrape_handler,
218+
&stats_event_sender,
219+
&http_stats_event_sender,
220+
&info_hashes,
221+
&original_peer_ip,
222+
)
223+
.await;
185224

186225
let mut expected_scrape_data = ScrapeData::empty();
187226
expected_scrape_data.add_file(
@@ -207,11 +246,27 @@ mod tests {
207246
let stats_event_sender: Arc<Option<Box<dyn statistics::event::sender::Sender>>> =
208247
Arc::new(Some(Box::new(stats_event_sender_mock)));
209248

249+
let mut http_stats_event_sender_mock = MockHttpStatsEventSender::new();
250+
http_stats_event_sender_mock
251+
.expect_send_event()
252+
.with(eq(http_tracker_core::statistics::event::Event::Tcp4Scrape))
253+
.times(1)
254+
.returning(|_| Box::pin(future::ready(Some(Ok(())))));
255+
let http_stats_event_sender: Arc<Option<Box<dyn http_tracker_core::statistics::event::sender::Sender>>> =
256+
Arc::new(Some(Box::new(http_stats_event_sender_mock)));
257+
210258
let scrape_handler = initialize_scrape_handler();
211259

212260
let peer_ip = IpAddr::V4(Ipv4Addr::new(126, 0, 0, 1));
213261

214-
invoke(&scrape_handler, &stats_event_sender, &sample_info_hashes(), &peer_ip).await;
262+
invoke(
263+
&scrape_handler,
264+
&stats_event_sender,
265+
&http_stats_event_sender,
266+
&sample_info_hashes(),
267+
&peer_ip,
268+
)
269+
.await;
215270
}
216271

217272
#[tokio::test]
@@ -225,11 +280,27 @@ mod tests {
225280
let stats_event_sender: Arc<Option<Box<dyn statistics::event::sender::Sender>>> =
226281
Arc::new(Some(Box::new(stats_event_sender_mock)));
227282

283+
let mut http_stats_event_sender_mock = MockHttpStatsEventSender::new();
284+
http_stats_event_sender_mock
285+
.expect_send_event()
286+
.with(eq(http_tracker_core::statistics::event::Event::Tcp6Scrape))
287+
.times(1)
288+
.returning(|_| Box::pin(future::ready(Some(Ok(())))));
289+
let http_stats_event_sender: Arc<Option<Box<dyn http_tracker_core::statistics::event::sender::Sender>>> =
290+
Arc::new(Some(Box::new(http_stats_event_sender_mock)));
291+
228292
let scrape_handler = initialize_scrape_handler();
229293

230294
let peer_ip = IpAddr::V6(Ipv6Addr::new(0x6969, 0x6969, 0x6969, 0x6969, 0x6969, 0x6969, 0x6969, 0x6969));
231295

232-
invoke(&scrape_handler, &stats_event_sender, &sample_info_hashes(), &peer_ip).await;
296+
invoke(
297+
&scrape_handler,
298+
&stats_event_sender,
299+
&http_stats_event_sender,
300+
&sample_info_hashes(),
301+
&peer_ip,
302+
)
303+
.await;
233304
}
234305
}
235306

@@ -244,18 +315,22 @@ mod tests {
244315
use packages::statistics;
245316
use torrust_tracker_primitives::core::ScrapeData;
246317

247-
use crate::packages;
318+
use crate::packages::{self, http_tracker_core};
248319
use crate::servers::http::v1::services::scrape::fake;
249320
use crate::servers::http::v1::services::scrape::tests::{
250321
initialize_announce_and_scrape_handlers_for_public_tracker, sample_info_hash, sample_info_hashes, sample_peer,
251-
MockStatsEventSender,
322+
MockHttpStatsEventSender, MockStatsEventSender,
252323
};
253324

254325
#[tokio::test]
255326
async fn it_should_always_return_the_zeroed_scrape_data_for_a_torrent() {
256327
let (stats_event_sender, _stats_repository) = packages::statistics::setup::factory(false);
257328
let stats_event_sender = Arc::new(stats_event_sender);
258329

330+
let (http_stats_event_sender, _http_stats_repository) =
331+
packages::http_tracker_core::statistics::setup::factory(false);
332+
let http_stats_event_sender = Arc::new(http_stats_event_sender);
333+
259334
let (announce_handler, _scrape_handler) = initialize_announce_and_scrape_handlers_for_public_tracker();
260335

261336
let info_hash = sample_info_hash();
@@ -266,7 +341,7 @@ mod tests {
266341
let original_peer_ip = peer.ip();
267342
announce_handler.announce(&info_hash, &mut peer, &original_peer_ip, &PeersWanted::All);
268343

269-
let scrape_data = fake(&stats_event_sender, &info_hashes, &original_peer_ip).await;
344+
let scrape_data = fake(&stats_event_sender, &http_stats_event_sender, &info_hashes, &original_peer_ip).await;
270345

271346
let expected_scrape_data = ScrapeData::zeroed(&info_hashes);
272347

@@ -284,9 +359,18 @@ mod tests {
284359
let stats_event_sender: Arc<Option<Box<dyn statistics::event::sender::Sender>>> =
285360
Arc::new(Some(Box::new(stats_event_sender_mock)));
286361

362+
let mut http_stats_event_sender_mock = MockHttpStatsEventSender::new();
363+
http_stats_event_sender_mock
364+
.expect_send_event()
365+
.with(eq(http_tracker_core::statistics::event::Event::Tcp4Scrape))
366+
.times(1)
367+
.returning(|_| Box::pin(future::ready(Some(Ok(())))));
368+
let http_stats_event_sender: Arc<Option<Box<dyn http_tracker_core::statistics::event::sender::Sender>>> =
369+
Arc::new(Some(Box::new(http_stats_event_sender_mock)));
370+
287371
let peer_ip = IpAddr::V4(Ipv4Addr::new(126, 0, 0, 1));
288372

289-
fake(&stats_event_sender, &sample_info_hashes(), &peer_ip).await;
373+
fake(&stats_event_sender, &http_stats_event_sender, &sample_info_hashes(), &peer_ip).await;
290374
}
291375

292376
#[tokio::test]
@@ -300,9 +384,18 @@ mod tests {
300384
let stats_event_sender: Arc<Option<Box<dyn statistics::event::sender::Sender>>> =
301385
Arc::new(Some(Box::new(stats_event_sender_mock)));
302386

387+
let mut http_stats_event_sender_mock = MockHttpStatsEventSender::new();
388+
http_stats_event_sender_mock
389+
.expect_send_event()
390+
.with(eq(http_tracker_core::statistics::event::Event::Tcp6Scrape))
391+
.times(1)
392+
.returning(|_| Box::pin(future::ready(Some(Ok(())))));
393+
let http_stats_event_sender: Arc<Option<Box<dyn http_tracker_core::statistics::event::sender::Sender>>> =
394+
Arc::new(Some(Box::new(http_stats_event_sender_mock)));
395+
303396
let peer_ip = IpAddr::V6(Ipv6Addr::new(0x6969, 0x6969, 0x6969, 0x6969, 0x6969, 0x6969, 0x6969, 0x6969));
304397

305-
fake(&stats_event_sender, &sample_info_hashes(), &peer_ip).await;
398+
fake(&stats_event_sender, &http_stats_event_sender, &sample_info_hashes(), &peer_ip).await;
306399
}
307400
}
308401
}

‎tests/servers/http/environment.rs

+1
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ impl Environment<Stopped> {
6262
scrape_handler: app_container.scrape_handler.clone(),
6363
whitelist_authorization: app_container.whitelist_authorization.clone(),
6464
stats_event_sender: app_container.stats_event_sender.clone(),
65+
http_stats_event_sender: app_container.http_stats_event_sender.clone(),
6566
authentication_service: app_container.authentication_service.clone(),
6667
});
6768

0 commit comments

Comments
 (0)
Please sign in to comment.