mirror of
https://github.com/YGGverse/aquatic.git
synced 2026-04-02 18:55:32 +00:00
udp: prometheus metrics for peers per torrent, add p999
This commit is contained in:
parent
5276a919da
commit
9e7e56b082
3 changed files with 106 additions and 10 deletions
|
|
@ -128,6 +128,9 @@ impl StatisticsCollector {
|
||||||
"worker_index" => worker_index.to_string(),
|
"worker_index" => worker_index.to_string(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
self.last_complete_histogram
|
||||||
|
.update_metrics(self.ip_version.clone());
|
||||||
}
|
}
|
||||||
|
|
||||||
let num_peers: usize = num_peers_by_worker.into_iter().sum();
|
let num_peers: usize = num_peers_by_worker.into_iter().sum();
|
||||||
|
|
@ -188,7 +191,7 @@ pub struct CollectedStatistics {
|
||||||
|
|
||||||
#[derive(Clone, Debug, Serialize, Default)]
|
#[derive(Clone, Debug, Serialize, Default)]
|
||||||
pub struct PeerHistogramStatistics {
|
pub struct PeerHistogramStatistics {
|
||||||
pub p0: u64,
|
pub min: u64,
|
||||||
pub p10: u64,
|
pub p10: u64,
|
||||||
pub p20: u64,
|
pub p20: u64,
|
||||||
pub p30: u64,
|
pub p30: u64,
|
||||||
|
|
@ -200,13 +203,14 @@ pub struct PeerHistogramStatistics {
|
||||||
pub p90: u64,
|
pub p90: u64,
|
||||||
pub p95: u64,
|
pub p95: u64,
|
||||||
pub p99: u64,
|
pub p99: u64,
|
||||||
pub p100: u64,
|
pub p999: u64,
|
||||||
|
pub max: u64,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl PeerHistogramStatistics {
|
impl PeerHistogramStatistics {
|
||||||
fn new(h: Histogram<u64>) -> Self {
|
fn new(h: Histogram<u64>) -> Self {
|
||||||
Self {
|
Self {
|
||||||
p0: h.value_at_percentile(0.0),
|
min: h.min(),
|
||||||
p10: h.value_at_percentile(10.0),
|
p10: h.value_at_percentile(10.0),
|
||||||
p20: h.value_at_percentile(20.0),
|
p20: h.value_at_percentile(20.0),
|
||||||
p30: h.value_at_percentile(30.0),
|
p30: h.value_at_percentile(30.0),
|
||||||
|
|
@ -218,7 +222,90 @@ impl PeerHistogramStatistics {
|
||||||
p90: h.value_at_percentile(90.0),
|
p90: h.value_at_percentile(90.0),
|
||||||
p95: h.value_at_percentile(95.0),
|
p95: h.value_at_percentile(95.0),
|
||||||
p99: h.value_at_percentile(99.0),
|
p99: h.value_at_percentile(99.0),
|
||||||
p100: h.value_at_percentile(100.0),
|
p999: h.value_at_percentile(99.9),
|
||||||
|
max: h.max(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "prometheus")]
|
||||||
|
fn update_metrics(&self, ip_version: String) {
|
||||||
|
::metrics::gauge!(
|
||||||
|
"aquatic_peers_per_torrent",
|
||||||
|
self.min as f64,
|
||||||
|
"type" => "max",
|
||||||
|
"ip_version" => ip_version.clone(),
|
||||||
|
);
|
||||||
|
::metrics::gauge!(
|
||||||
|
"aquatic_peers_per_torrent",
|
||||||
|
self.p10 as f64,
|
||||||
|
"type" => "p10",
|
||||||
|
"ip_version" => ip_version.clone(),
|
||||||
|
);
|
||||||
|
::metrics::gauge!(
|
||||||
|
"aquatic_peers_per_torrent",
|
||||||
|
self.p20 as f64,
|
||||||
|
"type" => "p20",
|
||||||
|
"ip_version" => ip_version.clone(),
|
||||||
|
);
|
||||||
|
::metrics::gauge!(
|
||||||
|
"aquatic_peers_per_torrent",
|
||||||
|
self.p30 as f64,
|
||||||
|
"type" => "p30",
|
||||||
|
"ip_version" => ip_version.clone(),
|
||||||
|
);
|
||||||
|
::metrics::gauge!(
|
||||||
|
"aquatic_peers_per_torrent",
|
||||||
|
self.p40 as f64,
|
||||||
|
"type" => "p40",
|
||||||
|
"ip_version" => ip_version.clone(),
|
||||||
|
);
|
||||||
|
::metrics::gauge!(
|
||||||
|
"aquatic_peers_per_torrent",
|
||||||
|
self.p50 as f64,
|
||||||
|
"type" => "p50",
|
||||||
|
"ip_version" => ip_version.clone(),
|
||||||
|
);
|
||||||
|
::metrics::gauge!(
|
||||||
|
"aquatic_peers_per_torrent",
|
||||||
|
self.p60 as f64,
|
||||||
|
"type" => "p60",
|
||||||
|
"ip_version" => ip_version.clone(),
|
||||||
|
);
|
||||||
|
::metrics::gauge!(
|
||||||
|
"aquatic_peers_per_torrent",
|
||||||
|
self.p70 as f64,
|
||||||
|
"type" => "p70",
|
||||||
|
"ip_version" => ip_version.clone(),
|
||||||
|
);
|
||||||
|
::metrics::gauge!(
|
||||||
|
"aquatic_peers_per_torrent",
|
||||||
|
self.p80 as f64,
|
||||||
|
"type" => "p80",
|
||||||
|
"ip_version" => ip_version.clone(),
|
||||||
|
);
|
||||||
|
::metrics::gauge!(
|
||||||
|
"aquatic_peers_per_torrent",
|
||||||
|
self.p90 as f64,
|
||||||
|
"type" => "p90",
|
||||||
|
"ip_version" => ip_version.clone(),
|
||||||
|
);
|
||||||
|
::metrics::gauge!(
|
||||||
|
"aquatic_peers_per_torrent",
|
||||||
|
self.p99 as f64,
|
||||||
|
"type" => "p99",
|
||||||
|
"ip_version" => ip_version.clone(),
|
||||||
|
);
|
||||||
|
::metrics::gauge!(
|
||||||
|
"aquatic_peers_per_torrent",
|
||||||
|
self.p999 as f64,
|
||||||
|
"type" => "p99.9",
|
||||||
|
"ip_version" => ip_version.clone(),
|
||||||
|
);
|
||||||
|
::metrics::gauge!(
|
||||||
|
"aquatic_peers_per_torrent",
|
||||||
|
self.max as f64,
|
||||||
|
"type" => "max",
|
||||||
|
"ip_version" => ip_version.clone(),
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -151,7 +151,7 @@ fn print_to_stdout(config: &Config, statistics: &CollectedStatistics) {
|
||||||
" peers per torrent (updated every {}s)",
|
" peers per torrent (updated every {}s)",
|
||||||
config.cleaning.torrent_cleaning_interval
|
config.cleaning.torrent_cleaning_interval
|
||||||
);
|
);
|
||||||
println!(" min {:>10}", statistics.peer_histogram.p0);
|
println!(" min {:>10}", statistics.peer_histogram.min);
|
||||||
println!(" p10 {:>10}", statistics.peer_histogram.p10);
|
println!(" p10 {:>10}", statistics.peer_histogram.p10);
|
||||||
println!(" p20 {:>10}", statistics.peer_histogram.p20);
|
println!(" p20 {:>10}", statistics.peer_histogram.p20);
|
||||||
println!(" p30 {:>10}", statistics.peer_histogram.p30);
|
println!(" p30 {:>10}", statistics.peer_histogram.p30);
|
||||||
|
|
@ -163,7 +163,8 @@ fn print_to_stdout(config: &Config, statistics: &CollectedStatistics) {
|
||||||
println!(" p90 {:>10}", statistics.peer_histogram.p90);
|
println!(" p90 {:>10}", statistics.peer_histogram.p90);
|
||||||
println!(" p95 {:>10}", statistics.peer_histogram.p95);
|
println!(" p95 {:>10}", statistics.peer_histogram.p95);
|
||||||
println!(" p99 {:>10}", statistics.peer_histogram.p99);
|
println!(" p99 {:>10}", statistics.peer_histogram.p99);
|
||||||
println!(" max {:>10}", statistics.peer_histogram.p100);
|
println!(" p99.9 {:>10}", statistics.peer_histogram.p999);
|
||||||
|
println!(" max {:>10}", statistics.peer_histogram.max);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -76,7 +76,7 @@
|
||||||
<caption>Updated every { peer_update_interval } seconds</caption>
|
<caption>Updated every { peer_update_interval } seconds</caption>
|
||||||
<tr>
|
<tr>
|
||||||
<th scope="row">Minimum</th>
|
<th scope="row">Minimum</th>
|
||||||
<td>{ ipv4.peer_histogram.p0 }</td>
|
<td>{ ipv4.peer_histogram.min }</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th scope="row">10th percentile</th>
|
<th scope="row">10th percentile</th>
|
||||||
|
|
@ -122,9 +122,13 @@
|
||||||
<th scope="row">99th percentile</th>
|
<th scope="row">99th percentile</th>
|
||||||
<td>{ ipv4.peer_histogram.p99 }</td>
|
<td>{ ipv4.peer_histogram.p99 }</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th scope="row">99.9th percentile</th>
|
||||||
|
<td>{ ipv4.peer_histogram.p999 }</td>
|
||||||
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th scope="row">Maximum</th>
|
<th scope="row">Maximum</th>
|
||||||
<td>{ ipv4.peer_histogram.p100 }</td>
|
<td>{ ipv4.peer_histogram.max }</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
|
|
@ -188,7 +192,7 @@
|
||||||
<caption>Updated every { peer_update_interval } seconds</caption>
|
<caption>Updated every { peer_update_interval } seconds</caption>
|
||||||
<tr>
|
<tr>
|
||||||
<th scope="row">Minimum</th>
|
<th scope="row">Minimum</th>
|
||||||
<td>{ ipv6.peer_histogram.p0 }</td>
|
<td>{ ipv6.peer_histogram.min }</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th scope="row">10th percentile</th>
|
<th scope="row">10th percentile</th>
|
||||||
|
|
@ -234,9 +238,13 @@
|
||||||
<th scope="row">99th percentile</th>
|
<th scope="row">99th percentile</th>
|
||||||
<td>{ ipv6.peer_histogram.p99 }</td>
|
<td>{ ipv6.peer_histogram.p99 }</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th scope="row">99.9th percentile</th>
|
||||||
|
<td>{ ipv6.peer_histogram.p999 }</td>
|
||||||
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th scope="row">Maximum</th>
|
<th scope="row">Maximum</th>
|
||||||
<td>{ ipv6.peer_histogram.p100 }</td>
|
<td>{ ipv6.peer_histogram.max }</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue