Skip to content

Commit d88dc9e

Browse files
committed
Expose 'timeout' on BytesThrottleConfig as timeout_millis
Signed-off-by: Brian L. Troutwine <brian.troutwine@datadoghq.com>
1 parent ad37873 commit d88dc9e

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
88
## Added
99
- Added configuration surface area to the OTel logs payload generator, in a
1010
manner similar to OTel metrics.
11+
- Stable throttle now has a 'timeout' configuration parameter to model IO done
12+
with timeout.
1113

1214
## [0.27.0]
1315
## Added

lading/src/generator/common.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ pub enum BytesThrottleConfig {
1515
Stable {
1616
/// The bytes per second rate limit (e.g., "1MB", "512KiB")
1717
bytes_per_second: Byte,
18+
/// The timeout in milliseconds for IO operations. Default is 0.
19+
#[serde(default)]
20+
timeout_millis: u64,
1821
},
1922
/// A throttle that linearly increases load over time
2023
Linear {
@@ -45,7 +48,10 @@ impl TryFrom<BytesThrottleConfig> for lading_throttle::Config {
4548
fn try_from(config: BytesThrottleConfig) -> Result<Self, Self::Error> {
4649
match config {
4750
BytesThrottleConfig::AllOut => Ok(lading_throttle::Config::AllOut),
48-
BytesThrottleConfig::Stable { bytes_per_second } => {
51+
BytesThrottleConfig::Stable {
52+
bytes_per_second,
53+
timeout_millis,
54+
} => {
4955
let value = bytes_per_second.as_u128();
5056
if value > u128::from(u32::MAX) {
5157
return Err(ThrottleConversionError::ValueTooLarge(bytes_per_second));
@@ -54,7 +60,7 @@ impl TryFrom<BytesThrottleConfig> for lading_throttle::Config {
5460
let value = NonZeroU32::new(value).ok_or(ThrottleConversionError::Zero)?;
5561
Ok(lading_throttle::Config::Stable {
5662
maximum_capacity: value,
57-
timeout_micros: 0,
63+
timeout_micros: timeout_millis.saturating_mul(1000),
5864
})
5965
}
6066
BytesThrottleConfig::Linear {

0 commit comments

Comments
 (0)