udp: improve statistics structs

- Now, workers don't need to keep track of which atomic usize
  to update
- Additionally, prometheus now gets separate information per
  socket worker
This commit is contained in:
Joakim Frostegård 2024-02-02 13:37:43 +01:00
parent e2e525b560
commit 405bbaca93
12 changed files with 400 additions and 294 deletions

View file

@ -44,6 +44,7 @@ struct TemplateData {
pub fn run_statistics_worker(
config: Config,
shared_state: State,
statistics: Statistics,
statistics_receiver: Receiver<StatisticsMessage>,
) -> anyhow::Result<()> {
let process_peer_client_data = {
@ -68,16 +69,8 @@ pub fn run_statistics_worker(
None
};
let mut ipv4_collector = StatisticsCollector::new(
shared_state.statistics_ipv4,
#[cfg(feature = "prometheus")]
"4".into(),
);
let mut ipv6_collector = StatisticsCollector::new(
shared_state.statistics_ipv6,
#[cfg(feature = "prometheus")]
"6".into(),
);
let mut ipv4_collector = StatisticsCollector::new(statistics.clone(), IpVersion::V4);
let mut ipv6_collector = StatisticsCollector::new(statistics, IpVersion::V6);
// Store a count to enable not removing peers from the count completely
// just because they were removed from one torrent