forked from torrust/torrust-tracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmetrics.rs
More file actions
118 lines (89 loc) · 4.01 KB
/
Copy pathmetrics.rs
File metadata and controls
118 lines (89 loc) · 4.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
use torrust_tracker_primitives::swarm_metadata::AggregateActiveSwarmMetadata;
/// Metrics collected by the tracker at the swarm layer.
#[derive(Copy, Clone, Debug, PartialEq, Default)]
pub struct TorrentsMetrics {
/// Total number of peers that have ever completed downloading.
pub total_downloaded: u64,
/// Total number of seeders.
pub total_complete: u64,
/// Total number of leechers.
pub total_incomplete: u64,
/// Total number of torrents.
pub total_torrents: u64,
}
impl From<AggregateActiveSwarmMetadata> for TorrentsMetrics {
fn from(value: AggregateActiveSwarmMetadata) -> Self {
Self {
total_downloaded: value.total_downloaded,
total_complete: value.total_complete,
total_incomplete: value.total_incomplete,
total_torrents: value.total_torrents,
}
}
}
/// Metrics collected by the tracker at the delivery layer.
///
/// - Number of connections handled
/// - Number of `announce` requests handled
/// - Number of `scrape` request handled
///
/// These metrics are collected for each connection type: UDP and HTTP
/// and also for each IP version used by the peers: IPv4 and IPv6.
#[derive(Debug, PartialEq, Default)]
pub struct ProtocolMetrics {
/// Total number of TCP (HTTP tracker) connections from IPv4 peers.
/// Since the HTTP tracker spec does not require a handshake, this metric
/// increases for every HTTP request.
#[deprecated(since = "3.1.0")]
pub tcp4_connections_handled: u64,
/// Total number of TCP (HTTP tracker) `announce` requests from IPv4 peers.
pub tcp4_announces_handled: u64,
/// Total number of TCP (HTTP tracker) `scrape` requests from IPv4 peers.
pub tcp4_scrapes_handled: u64,
/// Total number of TCP (HTTP tracker) connections from IPv6 peers.
#[deprecated(since = "3.1.0")]
pub tcp6_connections_handled: u64,
/// Total number of TCP (HTTP tracker) `announce` requests from IPv6 peers.
pub tcp6_announces_handled: u64,
/// Total number of TCP (HTTP tracker) `scrape` requests from IPv6 peers.
pub tcp6_scrapes_handled: u64,
// UDP
/// Total number of UDP (UDP tracker) requests aborted.
pub udp_requests_aborted: u64,
/// Total number of UDP (UDP tracker) requests banned.
pub udp_requests_banned: u64,
/// Total number of banned IPs.
pub udp_banned_ips_total: u64,
/// Average rounded time spent processing UDP connect requests.
pub udp_avg_connect_processing_time_ns: u64,
/// Average rounded time spent processing UDP announce requests.
pub udp_avg_announce_processing_time_ns: u64,
/// Average rounded time spent processing UDP scrape requests.
pub udp_avg_scrape_processing_time_ns: u64,
// UDPv4
/// Total number of UDP (UDP tracker) requests from IPv4 peers.
pub udp4_requests: u64,
/// Total number of UDP (UDP tracker) connections from IPv4 peers.
pub udp4_connections_handled: u64,
/// Total number of UDP (UDP tracker) `announce` requests from IPv4 peers.
pub udp4_announces_handled: u64,
/// Total number of UDP (UDP tracker) `scrape` requests from IPv4 peers.
pub udp4_scrapes_handled: u64,
/// Total number of UDP (UDP tracker) responses from IPv4 peers.
pub udp4_responses: u64,
/// Total number of UDP (UDP tracker) `error` requests from IPv4 peers.
pub udp4_errors_handled: u64,
// UDPv6
/// Total number of UDP (UDP tracker) requests from IPv6 peers.
pub udp6_requests: u64,
/// Total number of UDP (UDP tracker) `connection` requests from IPv6 peers.
pub udp6_connections_handled: u64,
/// Total number of UDP (UDP tracker) `announce` requests from IPv6 peers.
pub udp6_announces_handled: u64,
/// Total number of UDP (UDP tracker) `scrape` requests from IPv6 peers.
pub udp6_scrapes_handled: u64,
/// Total number of UDP (UDP tracker) responses from IPv6 peers.
pub udp6_responses: u64,
/// Total number of UDP (UDP tracker) `error` requests from IPv6 peers.
pub udp6_errors_handled: u64,
}