Skip to content

Commit 891a604

Browse files
committed
throttler error cleanup
1 parent 7a819ad commit 891a604

11 files changed

Lines changed: 35 additions & 16 deletions

File tree

lading/src/generator/file_gen/logrotate.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ impl Child {
382382
&self.labels).await?;
383383
}
384384
Err(err) => {
385-
error!("Throttle request of {} is larger than throttle capacity. Block will be discarded. Error: {}", total_bytes, err);
385+
error!("Discarding block due to throttle error: {err}");
386386
}
387387
}
388388
}

lading/src/generator/file_gen/traditional.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ impl Child {
351351
}
352352
}
353353
Err(err) => {
354-
error!("Throttle request of {total_bytes} is larger than throttle capacity. Block will be discarded. Error: {err}");
354+
error!("Discarding block due to throttle error: {err}");
355355
}
356356
}
357357
}

lading/src/generator/http.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ impl Http {
285285

286286
}
287287
Err(err) => {
288-
error!("Throttle request of {total_bytes} is larger than throttle capacity. Block will be discarded. Error: {err}");
288+
error!("Discarding block due to throttle error: {err}");
289289
}
290290
}
291291
},

lading/src/generator/splunk_hec.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ impl SplunkHec {
319319
tokio::spawn(send_hec_request(permit, block_length, labels, channel, client, request, request_shutdown.clone(), uri_clone));
320320
}
321321
Err(err) => {
322-
error!("Throttle request of {total_bytes} is larger than throttle capacity. Block will be discarded. Error: {err}");
322+
error!("Discarding block due to throttle error: {err}");
323323
}
324324
}
325325
}

lading/src/generator/tcp.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ impl TcpWorker {
272272
}
273273
}
274274
Err(err) => {
275-
error!("Throttle request of {total_bytes} is larger than throttle capacity. Block will be discarded. Error: {err}");
275+
error!("Discarding block due to throttle error: {err}");
276276
}
277277
}
278278
}

lading/src/generator/trace_agent.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ impl TraceAgent {
378378
});
379379
}
380380
Err(err) => {
381-
error!("Throttle request of {total_bytes} is larger than throttle capacity. Block will be discarded. Error: {err}", total_bytes = total_bytes);
381+
error!("Discarding block due to throttle error: {err}");
382382
}
383383
}
384384
},

lading/src/generator/udp.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ impl UdpWorker {
275275
}
276276
}
277277
Err(err) => {
278-
error!("Throttle request of {total_bytes} is larger than throttle capacity. Block will be discarded. Error: {err}");
278+
error!("Discarding block due to throttle error: {err}");
279279
}
280280
}
281281
}

lading/src/generator/unix_datagram.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ impl Child {
298298
}
299299
}
300300
Err(err) => {
301-
error!("Throttle request of {total_bytes} is larger than throttle capacity. Block will be discarded. Error: {err}");
301+
error!("Discarding block due to throttle error: {err}");
302302
}
303303
}
304304
}

lading/src/generator/unix_stream.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ impl Child {
321321
}
322322
}
323323
Err(err) => {
324-
error!("Throttle request of {total_bytes} is larger than throttle capacity. Block will be discarded. Error: {err}");
324+
error!("Discarding block due to throttle error: {err}");
325325
}
326326
}
327327
}

lading_throttle/src/linear.rs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,13 @@ use super::{Clock, RealClock};
1212
#[derive(thiserror::Error, Debug, Clone, Copy)]
1313
pub enum Error {
1414
/// Requested capacity is greater than maximum allowed capacity.
15-
#[error("Capacity")]
16-
Capacity,
15+
#[error("capacity request {requested} exceeds maximum {maximum}")]
16+
Capacity {
17+
/// The requested capacity that exceeded the maximum.
18+
requested: u32,
19+
/// The maximum capacity permitted by the throttle.
20+
maximum: u32,
21+
},
1722
}
1823

1924
#[derive(Debug)]
@@ -133,7 +138,10 @@ impl Valve {
133138
// ticker if the caller makes a zero request. It's strange but it's a
134139
// valid thing to do.
135140
if capacity_request > self.maximum_capacity {
136-
return Err(Error::Capacity);
141+
return Err(Error::Capacity {
142+
requested: capacity_request,
143+
maximum: self.maximum_capacity,
144+
});
137145
}
138146

139147
let current_interval = ticks_elapsed / INTERVAL_TICKS;

0 commit comments

Comments
 (0)