Loading src/handlers/bandwidth.rs +2 −42 Original line number Diff line number Diff line Loading @@ -28,27 +28,7 @@ pub async fn get_bandwidth( .await .map_err(ErrorInternalServerError)? .into_iter() .map(|x| { let write_history = VictoriaMetricsRefBuilder::new() .with_metric(MetricsLabel::WriteBandwidthHistory) .with_fingerprint(x.fingerprint.clone()) .build() .unwrap(); let read_history = VictoriaMetricsRefBuilder::new() .with_metric(MetricsLabel::ReadBandwidthHistory) .with_fingerprint(x.fingerprint.clone()) .build() .unwrap(); RelayBandwidth::new( x.fingerprint, Some(write_history), Some(read_history), x.overload_ratelimits_ratelimit, x.overload_fd_exhausted_timestamp.map(|x| x.to_string()), ) }) .map(|x| RelayBandwidth::from(x)) .collect(); response.relays(relays); Loading @@ -60,27 +40,7 @@ pub async fn get_bandwidth( .await .map_err(ErrorInternalServerError)? .into_iter() .map(|x| { let write_history = VictoriaMetricsRefBuilder::new() .with_metric(MetricsLabel::WriteBandwidthHistory) .with_fingerprint(x.fingerprint.clone()) .build() .unwrap(); let read_history = VictoriaMetricsRefBuilder::new() .with_metric(MetricsLabel::ReadBandwidthHistory) .with_fingerprint(x.fingerprint.clone()) .build() .unwrap(); BridgeBandwidth::new( x.fingerprint, Some(write_history), Some(read_history), x.overload_ratelimits_ratelimit, x.overload_fd_exhausted_timestamp.map(|x| x.to_string()), ) }) .map(|x| BridgeBandwidth::from(x)) .collect(); response.bridges(bridges); Loading src/models/responses/bandwidth.rs +52 −1 Original line number Diff line number Diff line Loading @@ -2,7 +2,10 @@ use actix_web::Responder; use serde::{Deserialize, Serialize}; use serde_with::skip_serializing_none; use crate::victoriametrics::VictoriaMetricsRef; use crate::{ metrics::{BridgeBandwidthRow, RelayBandwidthRow}, victoriametrics::{labels::MetricsLabel, VictoriaMetricsRef, VictoriaMetricsRefBuilder}, }; #[skip_serializing_none] #[derive(Debug, Clone, Serialize, Deserialize)] Loading Loading @@ -63,6 +66,30 @@ impl RelayBandwidth { } } impl From<RelayBandwidthRow> for RelayBandwidth { fn from(rbr: RelayBandwidthRow) -> Self { let write_history = VictoriaMetricsRefBuilder::new() .with_metric(MetricsLabel::WriteBandwidthHistory) .with_fingerprint(rbr.fingerprint.clone()) .build() .unwrap(); let read_history = VictoriaMetricsRefBuilder::new() .with_metric(MetricsLabel::ReadBandwidthHistory) .with_fingerprint(rbr.fingerprint.clone()) .build() .unwrap(); RelayBandwidth::new( rbr.fingerprint, Some(write_history), Some(read_history), rbr.overload_ratelimits_ratelimit, rbr.overload_fd_exhausted_timestamp.map(|x| x.to_string()), ) } } #[skip_serializing_none] #[derive(Debug, Clone, Serialize, Deserialize)] pub struct BridgeBandwidth { Loading Loading @@ -115,3 +142,27 @@ impl BridgeBandwidth { } } } impl From<BridgeBandwidthRow> for BridgeBandwidth { fn from(bbr: BridgeBandwidthRow) -> Self { let write_history = VictoriaMetricsRefBuilder::new() .with_metric(MetricsLabel::WriteBandwidthHistory) .with_fingerprint(bbr.fingerprint.clone()) .build() .unwrap(); let read_history = VictoriaMetricsRefBuilder::new() .with_metric(MetricsLabel::ReadBandwidthHistory) .with_fingerprint(bbr.fingerprint.clone()) .build() .unwrap(); BridgeBandwidth::new( bbr.fingerprint, Some(write_history), Some(read_history), bbr.overload_ratelimits_ratelimit, bbr.overload_fd_exhausted_timestamp.map(|x| x.to_string()), ) } } Loading
src/handlers/bandwidth.rs +2 −42 Original line number Diff line number Diff line Loading @@ -28,27 +28,7 @@ pub async fn get_bandwidth( .await .map_err(ErrorInternalServerError)? .into_iter() .map(|x| { let write_history = VictoriaMetricsRefBuilder::new() .with_metric(MetricsLabel::WriteBandwidthHistory) .with_fingerprint(x.fingerprint.clone()) .build() .unwrap(); let read_history = VictoriaMetricsRefBuilder::new() .with_metric(MetricsLabel::ReadBandwidthHistory) .with_fingerprint(x.fingerprint.clone()) .build() .unwrap(); RelayBandwidth::new( x.fingerprint, Some(write_history), Some(read_history), x.overload_ratelimits_ratelimit, x.overload_fd_exhausted_timestamp.map(|x| x.to_string()), ) }) .map(|x| RelayBandwidth::from(x)) .collect(); response.relays(relays); Loading @@ -60,27 +40,7 @@ pub async fn get_bandwidth( .await .map_err(ErrorInternalServerError)? .into_iter() .map(|x| { let write_history = VictoriaMetricsRefBuilder::new() .with_metric(MetricsLabel::WriteBandwidthHistory) .with_fingerprint(x.fingerprint.clone()) .build() .unwrap(); let read_history = VictoriaMetricsRefBuilder::new() .with_metric(MetricsLabel::ReadBandwidthHistory) .with_fingerprint(x.fingerprint.clone()) .build() .unwrap(); BridgeBandwidth::new( x.fingerprint, Some(write_history), Some(read_history), x.overload_ratelimits_ratelimit, x.overload_fd_exhausted_timestamp.map(|x| x.to_string()), ) }) .map(|x| BridgeBandwidth::from(x)) .collect(); response.bridges(bridges); Loading
src/models/responses/bandwidth.rs +52 −1 Original line number Diff line number Diff line Loading @@ -2,7 +2,10 @@ use actix_web::Responder; use serde::{Deserialize, Serialize}; use serde_with::skip_serializing_none; use crate::victoriametrics::VictoriaMetricsRef; use crate::{ metrics::{BridgeBandwidthRow, RelayBandwidthRow}, victoriametrics::{labels::MetricsLabel, VictoriaMetricsRef, VictoriaMetricsRefBuilder}, }; #[skip_serializing_none] #[derive(Debug, Clone, Serialize, Deserialize)] Loading Loading @@ -63,6 +66,30 @@ impl RelayBandwidth { } } impl From<RelayBandwidthRow> for RelayBandwidth { fn from(rbr: RelayBandwidthRow) -> Self { let write_history = VictoriaMetricsRefBuilder::new() .with_metric(MetricsLabel::WriteBandwidthHistory) .with_fingerprint(rbr.fingerprint.clone()) .build() .unwrap(); let read_history = VictoriaMetricsRefBuilder::new() .with_metric(MetricsLabel::ReadBandwidthHistory) .with_fingerprint(rbr.fingerprint.clone()) .build() .unwrap(); RelayBandwidth::new( rbr.fingerprint, Some(write_history), Some(read_history), rbr.overload_ratelimits_ratelimit, rbr.overload_fd_exhausted_timestamp.map(|x| x.to_string()), ) } } #[skip_serializing_none] #[derive(Debug, Clone, Serialize, Deserialize)] pub struct BridgeBandwidth { Loading Loading @@ -115,3 +142,27 @@ impl BridgeBandwidth { } } } impl From<BridgeBandwidthRow> for BridgeBandwidth { fn from(bbr: BridgeBandwidthRow) -> Self { let write_history = VictoriaMetricsRefBuilder::new() .with_metric(MetricsLabel::WriteBandwidthHistory) .with_fingerprint(bbr.fingerprint.clone()) .build() .unwrap(); let read_history = VictoriaMetricsRefBuilder::new() .with_metric(MetricsLabel::ReadBandwidthHistory) .with_fingerprint(bbr.fingerprint.clone()) .build() .unwrap(); BridgeBandwidth::new( bbr.fingerprint, Some(write_history), Some(read_history), bbr.overload_ratelimits_ratelimit, bbr.overload_fd_exhausted_timestamp.map(|x| x.to_string()), ) } }