diff --git a/lading/src/generator/file_gen/logrotate.rs b/lading/src/generator/file_gen/logrotate.rs index 5efdbbbb5..77101131e 100644 --- a/lading/src/generator/file_gen/logrotate.rs +++ b/lading/src/generator/file_gen/logrotate.rs @@ -382,7 +382,7 @@ impl Child { &self.labels).await?; } Err(err) => { - error!("Throttle request of {} is larger than throttle capacity. Block will be discarded. Error: {}", total_bytes, err); + error!("Discarding block due to throttle error: {err}"); } } } diff --git a/lading/src/generator/file_gen/traditional.rs b/lading/src/generator/file_gen/traditional.rs index 72ea23fd3..02b246670 100644 --- a/lading/src/generator/file_gen/traditional.rs +++ b/lading/src/generator/file_gen/traditional.rs @@ -351,7 +351,7 @@ impl Child { } } Err(err) => { - error!("Throttle request of {total_bytes} is larger than throttle capacity. Block will be discarded. Error: {err}"); + error!("Discarding block due to throttle error: {err}"); } } } diff --git a/lading/src/generator/http.rs b/lading/src/generator/http.rs index 3ba49a64d..c94ce97d7 100644 --- a/lading/src/generator/http.rs +++ b/lading/src/generator/http.rs @@ -285,7 +285,7 @@ impl Http { } Err(err) => { - error!("Throttle request of {total_bytes} is larger than throttle capacity. Block will be discarded. Error: {err}"); + error!("Discarding block due to throttle error: {err}"); } } }, diff --git a/lading/src/generator/splunk_hec.rs b/lading/src/generator/splunk_hec.rs index 9cc03e7a3..779e35486 100644 --- a/lading/src/generator/splunk_hec.rs +++ b/lading/src/generator/splunk_hec.rs @@ -319,7 +319,7 @@ impl SplunkHec { tokio::spawn(send_hec_request(permit, block_length, labels, channel, client, request, request_shutdown.clone(), uri_clone)); } Err(err) => { - error!("Throttle request of {total_bytes} is larger than throttle capacity. Block will be discarded. Error: {err}"); + error!("Discarding block due to throttle error: {err}"); } } } diff --git a/lading/src/generator/tcp.rs b/lading/src/generator/tcp.rs index 8bcdb3efe..c089f539e 100644 --- a/lading/src/generator/tcp.rs +++ b/lading/src/generator/tcp.rs @@ -272,7 +272,7 @@ impl TcpWorker { } } Err(err) => { - error!("Throttle request of {total_bytes} is larger than throttle capacity. Block will be discarded. Error: {err}"); + error!("Discarding block due to throttle error: {err}"); } } } diff --git a/lading/src/generator/trace_agent.rs b/lading/src/generator/trace_agent.rs index c31e8ef73..a4068b413 100644 --- a/lading/src/generator/trace_agent.rs +++ b/lading/src/generator/trace_agent.rs @@ -378,7 +378,7 @@ impl TraceAgent { }); } Err(err) => { - error!("Throttle request of {total_bytes} is larger than throttle capacity. Block will be discarded. Error: {err}", total_bytes = total_bytes); + error!("Discarding block due to throttle error: {err}"); } } }, diff --git a/lading/src/generator/udp.rs b/lading/src/generator/udp.rs index 3062ae8e5..3e84560b8 100644 --- a/lading/src/generator/udp.rs +++ b/lading/src/generator/udp.rs @@ -275,7 +275,7 @@ impl UdpWorker { } } Err(err) => { - error!("Throttle request of {total_bytes} is larger than throttle capacity. Block will be discarded. Error: {err}"); + error!("Discarding block due to throttle error: {err}"); } } } diff --git a/lading/src/generator/unix_datagram.rs b/lading/src/generator/unix_datagram.rs index 006e0cc78..b513bb302 100644 --- a/lading/src/generator/unix_datagram.rs +++ b/lading/src/generator/unix_datagram.rs @@ -298,7 +298,7 @@ impl Child { } } Err(err) => { - error!("Throttle request of {total_bytes} is larger than throttle capacity. Block will be discarded. Error: {err}"); + error!("Discarding block due to throttle error: {err}"); } } } diff --git a/lading/src/generator/unix_stream.rs b/lading/src/generator/unix_stream.rs index 366f20662..f2808ef11 100644 --- a/lading/src/generator/unix_stream.rs +++ b/lading/src/generator/unix_stream.rs @@ -321,7 +321,7 @@ impl Child { } } Err(err) => { - error!("Throttle request of {total_bytes} is larger than throttle capacity. Block will be discarded. Error: {err}"); + error!("Discarding block due to throttle error: {err}"); } } } diff --git a/lading_throttle/src/linear.rs b/lading_throttle/src/linear.rs index b06f6b576..5df496445 100644 --- a/lading_throttle/src/linear.rs +++ b/lading_throttle/src/linear.rs @@ -12,8 +12,13 @@ use super::{Clock, RealClock}; #[derive(thiserror::Error, Debug, Clone, Copy)] pub enum Error { /// Requested capacity is greater than maximum allowed capacity. - #[error("Capacity")] - Capacity, + #[error("capacity request {requested} exceeds maximum {maximum}")] + Capacity { + /// The requested capacity that exceeded the maximum. + requested: u32, + /// The maximum capacity permitted by the throttle. + maximum: u32, + }, } #[derive(Debug)] @@ -133,7 +138,10 @@ impl Valve { // ticker if the caller makes a zero request. It's strange but it's a // valid thing to do. if capacity_request > self.maximum_capacity { - return Err(Error::Capacity); + return Err(Error::Capacity { + requested: capacity_request, + maximum: self.maximum_capacity, + }); } let current_interval = ticks_elapsed / INTERVAL_TICKS; diff --git a/lading_throttle/src/stable.rs b/lading_throttle/src/stable.rs index c09895328..ab138c0bc 100644 --- a/lading_throttle/src/stable.rs +++ b/lading_throttle/src/stable.rs @@ -10,8 +10,13 @@ use super::{Clock, INTERVAL_TICKS, RealClock}; #[derive(thiserror::Error, Debug, Clone, Copy, PartialEq)] pub enum Error { /// Requested capacity is greater than maximum allowed capacity. - #[error("Capacity")] - Capacity, + #[error("capacity request {requested} exceeds throttle's maximum {maximum}")] + Capacity { + /// The requested capacity that exceeded the maximum. + requested: u32, + /// The maximum capacity permitted by the throttle. + maximum: u32, + }, } #[derive(Debug)] @@ -144,7 +149,10 @@ impl Valve { // ticker if the caller makes a zero request. It's strange but it's a // valid thing to do. if capacity_request > self.maximum_capacity { - return Err(Error::Capacity); + return Err(Error::Capacity { + requested: capacity_request, + maximum: self.maximum_capacity, + }); } let current_interval = tick_to_interval(ticks_elapsed); @@ -353,7 +361,10 @@ mod verification { capacity_request: u32, ) -> Result { if capacity_request > self.maximum_capacity { - return Err(super::Error::Capacity); + return Err(super::Error::Capacity { + requested: capacity_request, + maximum: self.maximum_capacity, + }); } let current_interval = tick_to_interval(ticks_elapsed);