Skip to content

Commit

Permalink
Clippy fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Firaenix committed Dec 27, 2024
1 parent d5960c8 commit 35353b6
Showing 4 changed files with 19 additions and 19 deletions.
12 changes: 6 additions & 6 deletions src/collectors/hls.rs
Original file line number Diff line number Diff line change
@@ -184,7 +184,7 @@ impl HlsCollector {
"isp" => node_info.isp.clone(),
"endpoint" => result.endpoint.clone()
)
.record(result.duration.unwrap_or_default() as f64 / 1000.0);
.record(result.duration.unwrap_or_default() / 1000.0);

gauge!(
format!("{}hls_master_size_bytes", prefix),
@@ -194,7 +194,7 @@ impl HlsCollector {
"isp" => node_info.isp.clone(),
"endpoint" => result.endpoint.clone()
)
.set(master.clone().unwrap().download_metrics.unwrap().size as f64);
.set(master.clone().unwrap().download_metrics.unwrap().size);

gauge!(
format!("{}hls_renditions_count", prefix),
@@ -216,7 +216,7 @@ impl HlsCollector {
"isp" => node_info.isp.clone(),
"endpoint" => result.endpoint.clone()
)
.record(metrics.tcp_connect_duration_ms as f64 / 1000.0);
.record(metrics.tcp_connect_duration_ms / 1000.0);

histogram!(
format!("{}hls_ttfb_duration_seconds", prefix),
@@ -226,7 +226,7 @@ impl HlsCollector {
"isp" => node_info.isp.clone(),
"endpoint" => result.endpoint.clone()
)
.record(metrics.http_ttfb_duration_ms as f64 / 1000.0);
.record(metrics.http_ttfb_duration_ms / 1000.0);

// ... other connection metrics
}
@@ -245,7 +245,7 @@ impl HlsCollector {
"resolution" => rendition.resolution.clone(),
"bandwidth" => rendition.bandwidth.to_string()
)
.record(fragment.download_metrics.clone().unwrap().time_ms as f64 / 1000.0);
.record(fragment.download_metrics.clone().unwrap().time_ms / 1000.0);

gauge!(
format!("{}hls_fragment_size_bytes", prefix),
@@ -257,7 +257,7 @@ impl HlsCollector {
"resolution" => rendition.resolution.clone(),
"bandwidth" => rendition.bandwidth.to_string()
)
.set(fragment.download_metrics.clone().unwrap().size as f64);
.set(fragment.download_metrics.clone().unwrap().size);

gauge!(
format!("{}hls_fragment_bandwidth_bytes_per_second", prefix),
14 changes: 7 additions & 7 deletions src/collectors/icmp.rs
Original file line number Diff line number Diff line change
@@ -173,7 +173,7 @@ impl IcmpCollector {
"endpoint" => result.endpoint.clone(),
"ip_address" => icmp_result.ip_address.clone()
)
.record(result.duration.unwrap_or(0.0) as f64 / 1000.0); // Convert ms to seconds
.record(result.duration.unwrap_or(0.0) / 1000.0); // Convert ms to seconds

// Record latency metrics
gauge!(
@@ -185,7 +185,7 @@ impl IcmpCollector {
"endpoint" => result.endpoint.clone(),
"ip_address" => icmp_result.ip_address.clone()
)
.set(icmp_result.min as f64);
.set(icmp_result.min);

gauge!(
format!("{}icmp_ping_latency_max_ms", prefix),
@@ -196,7 +196,7 @@ impl IcmpCollector {
"endpoint" => result.endpoint.clone(),
"ip_address" => icmp_result.ip_address.clone()
)
.set(icmp_result.max as f64);
.set(icmp_result.max);

gauge!(
format!("{}icmp_ping_latency_avg_ms", prefix),
@@ -230,7 +230,7 @@ impl IcmpCollector {
"endpoint" => result.endpoint.clone(),
"ip_address" => icmp_result.ip_address.clone()
)
.set(icmp_result.packet_loss as f64 / 100.0);
.set(icmp_result.packet_loss / 100.0);

gauge!(
format!("{}icmp_ping_packets_sent", prefix),
@@ -241,7 +241,7 @@ impl IcmpCollector {
"endpoint" => result.endpoint.clone(),
"ip_address" => icmp_result.ip_address.clone()
)
.set(icmp_result.packets_sent as f64);
.set(icmp_result.packets_sent);

gauge!(
format!("{}icmp_ping_packets_received", prefix),
@@ -252,11 +252,11 @@ impl IcmpCollector {
"endpoint" => result.endpoint.clone(),
"ip_address" => icmp_result.ip_address.clone()
)
.set(icmp_result.packets_recv as f64);
.set(icmp_result.packets_recv);

// Record success metrics
let success_ratio = if icmp_result.packets_sent > 0.0 {
icmp_result.packets_recv as f64 / icmp_result.packets_sent as f64
icmp_result.packets_recv / icmp_result.packets_sent
} else {
0.0
};
2 changes: 1 addition & 1 deletion src/config.rs
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@ use serde::Deserialize;

use eyre::{Context, Result};
use figment::{
providers::{Env, Format, Toml, Yaml},
providers::{Env, Format, Yaml},
Figment,
};
use strum::{AsRefStr, EnumString};
10 changes: 5 additions & 5 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
use crate::config::{Conf, MetricConfig, MetricType};
use crate::config::{Conf, MetricType};
use collectors::runner::run_collector;
use collectors::{dns, hls, icmp, Collector};
use color_eyre::eyre::{Context, Result};
use metrics_exporter_prometheus::{PrometheusBuilder, PrometheusHandle};
use poem::middleware::{AddData, Tracing};
use poem::middleware::AddData;
use poem::web::Data;
use poem::EndpointExt;
use poem::{get, handler, listener::TcpListener, web::Path, Route, Server};
use poem::{get, handler, listener::TcpListener, Route, Server};
use progenitor::generate_api;
use std::sync::{Arc, LazyLock};
use std::sync::LazyLock;
use tokio::join;
use tokio::task::LocalSet;
use tracing::{debug, error, info, instrument, warn};
use tracing::{error, info};

mod collectors;
mod config;

0 comments on commit 35353b6

Please sign in to comment.