Skip to content

Commit 6db059e

Browse files
chore(deps): Bump rand from 0.8.5 to 0.9.0 (vectordotdev#22403)
* chore(deps): Bump rand from 0.8.5 to 0.9.0 Bumps [rand](https://github.com/rust-random/rand) from 0.8.5 to 0.9.0. - [Release notes](https://github.com/rust-random/rand/releases) - [Changelog](https://github.com/rust-random/rand/blob/master/CHANGELOG.md) - [Commits](rust-random/rand@0.8.5...0.9.0) --- updated-dependencies: - dependency-name: rand dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]> * major updates * revert changes to the dreaded patch file * update test since rand behavior changed * update seed for 'decode_shuffled_messages' * rename to distr * update portpicker * dd-rust-license-tool write --------- Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Pavlos Rontidis <[email protected]>
1 parent 4854f06 commit 6db059e

File tree

32 files changed

+91
-92
lines changed

32 files changed

+91
-92
lines changed

Cargo.lock

+11-11
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+3-2
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,8 @@ prost = { version = "0.12", default-features = false, features = ["std"] }
155155
prost-build = { version = "0.12", default-features = false }
156156
prost-reflect = { version = "0.14", features = ["serde"], default-features = false }
157157
prost-types = { version = "0.12", default-features = false }
158-
rand = { version = "0.8.5", default-features = false, features = ["small_rng"] }
158+
rand = { version = "0.9.0", default-features = false, features = ["small_rng", "thread_rng"] }
159+
rand_distr = { version = "0.5.1", default-features = false }
159160
semver = { version = "1.0.25", default-features = false, features = ["serde", "std"] }
160161
serde_json = { version = "1.0.139", default-features = false, features = ["raw_value", "std"] }
161162
serde = { version = "1.0.218", default-features = false, features = ["alloc", "derive", "rc"] }
@@ -359,7 +360,7 @@ percent-encoding = { version = "2.3.1", default-features = false }
359360
postgres-openssl = { version = "0.5.1", default-features = false, features = ["runtime"], optional = true }
360361
pulsar = { version = "6.3.0", default-features = false, features = ["tokio-runtime", "auth-oauth2", "flate2", "lz4", "snap", "zstd"], optional = true }
361362
rand.workspace = true
362-
rand_distr = { version = "0.4.3", default-features = false }
363+
rand_distr.workspace = true
363364
rdkafka = { version = "0.37.0", default-features = false, features = ["curl-static", "tokio", "libz", "ssl", "zstd"], optional = true }
364365
redis = { version = "0.24.0", default-features = false, features = ["connection-manager", "tokio-comp", "tokio-native-tls-comp"], optional = true }
365366
regex = { version = "1.11.1", default-features = false, features = ["std", "perf"] }

LICENSE-3rdparty.csv

+1-1
Original file line numberDiff line numberDiff line change
@@ -493,7 +493,7 @@ radium,https://github.com/bitvecto-rs/radium,MIT,"Nika Layzell <nika@thelayzells
493493
radix_trie,https://github.com/michaelsproul/rust_radix_trie,MIT,Michael Sproul <[email protected]>
494494
rand,https://github.com/rust-random/rand,MIT OR Apache-2.0,"The Rand Project Developers, The Rust Project Developers"
495495
rand_chacha,https://github.com/rust-random/rand,MIT OR Apache-2.0,"The Rand Project Developers, The Rust Project Developers, The CryptoCorrosion Contributors"
496-
rand_distr,https://github.com/rust-random/rand,MIT OR Apache-2.0,The Rand Project Developers
496+
rand_distr,https://github.com/rust-random/rand_distr,MIT OR Apache-2.0,The Rand Project Developers
497497
rand_hc,https://github.com/rust-random/rand,MIT OR Apache-2.0,The Rand Project Developers
498498
rand_xorshift,https://github.com/rust-random/rngs,MIT OR Apache-2.0,"The Rand Project Developers, The Rust Project Developers"
499499
ratatui,https://github.com/ratatui/ratatui,MIT,"Florian Dehau <[email protected]>, The Ratatui Developers"

benches/distribution_statistic.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
use criterion::{criterion_group, criterion_main, BatchSize, Criterion};
22
use rand::{
3-
distributions::{Distribution, Uniform},
3+
distr::{Distribution, Uniform},
44
seq::SliceRandom,
55
};
66
use vector::{event::metric::Sample, sinks::util::statistic::DistributionStatistic};
77

88
fn generate_samples(mut size: u32, max_bin_count: u32) -> Vec<Sample> {
9-
let mut rng = rand::thread_rng();
9+
let mut rng = rand::rng();
1010
let range = Uniform::from(1..=max_bin_count);
1111
let mut value = 1.0;
1212
let mut samples = Vec::new();

lib/codecs/src/decoding/framing/chunked_gelf.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -511,7 +511,6 @@ impl Decoder for ChunkedGelfDecoder {
511511

512512
#[cfg(test)]
513513
mod tests {
514-
515514
use super::*;
516515
use bytes::{BufMut, BytesMut};
517516
use flate2::{write::GzEncoder, write::ZlibEncoder};
@@ -734,7 +733,7 @@ mod tests {
734733

735734
#[tokio::test]
736735
async fn decode_shuffled_messages() {
737-
let mut rng = SmallRng::seed_from_u64(420);
736+
let mut rng = SmallRng::seed_from_u64(42);
738737
let total_chunks = 100u8;
739738
let first_message_id = 1u64;
740739
let first_payload = "first payload";

lib/fakedata/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ license = "MPL-2.0"
99
[dependencies]
1010
chrono.workspace = true
1111
fakedata_generator = "0.5.0"
12-
rand = "0.8.5"
12+
rand.workspace = true

lib/fakedata/src/logs.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use chrono::{
44
SecondsFormat,
55
};
66
use fakedata_generator::{gen_domain, gen_ipv4, gen_username};
7-
use rand::{thread_rng, Rng};
7+
use rand::{rng, Rng};
88

99
static APPLICATION_NAMES: [&str; 10] = [
1010
"auth", "data", "deploy", "etl", "scraper", "cron", "ingress", "egress", "alerter", "fwd",
@@ -217,13 +217,13 @@ fn syslog_version() -> usize {
217217

218218
// Helper functions
219219
fn random_in_range(min: usize, max: usize) -> usize {
220-
thread_rng().gen_range(min..max)
220+
rng().random_range(min..max)
221221
}
222222

223223
fn random_from_array<T: ?Sized>(v: &'static [&'static T]) -> &'static T {
224-
v[thread_rng().gen_range(0..v.len())]
224+
v[rng().random_range(0..v.len())]
225225
}
226226

227227
fn random_from_array_copied<T: Copy>(v: &[T]) -> T {
228-
v[thread_rng().gen_range(0..v.len())]
228+
v[rng().random_range(0..v.len())]
229229
}

lib/k8s-e2e-tests/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ tokio = { version = "1.43.0", features = ["full"] }
1818
indoc = "2.0.5"
1919
env_logger = "0.11"
2020
tracing = { version = "0.1", features = ["log"] }
21-
rand = "0.8"
21+
rand.workspace = true
2222

2323
[features]
2424
e2e-tests = []

lib/k8s-e2e-tests/src/lib.rs

+4-9
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ use k8s_openapi::{
1010
use k8s_test_framework::{
1111
test_pod, wait_for_resource::WaitFor, CommandBuilder, Framework, Interface, Manager, Reader,
1212
};
13+
use rand::distr::{Alphanumeric, SampleString};
14+
use rand::rng;
1315
use tracing::{debug, error, info};
1416

1517
pub mod metrics;
@@ -21,16 +23,9 @@ pub fn init() {
2123
}
2224

2325
pub fn get_namespace() -> String {
24-
use rand::Rng;
25-
26-
// Generate a random alphanumeric (lowercase) string to ensure each test is run with unique
27-
// names.
26+
// Generate a random alphanumeric (lowercase) string to ensure each test is run with unique names.
2827
// There is a 36 ^ 5 chance of a name collision, which is likely to be an acceptable risk.
29-
let id: String = rand::thread_rng()
30-
.sample_iter(&rand::distributions::Alphanumeric)
31-
.take(5)
32-
.map(|num| (num as char).to_ascii_lowercase())
33-
.collect();
28+
let id = Alphanumeric.sample_string(&mut rng(), 5).to_lowercase();
3429

3530
format!("vector-{}", id)
3631
}

lib/portpicker/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ publish = false
77
license = "Unlicense"
88

99
[dependencies]
10-
rand = "0.8.5"
10+
rand.workspace = true

lib/portpicker/src/lib.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030

3131
use std::net::{IpAddr, SocketAddr, TcpListener, ToSocketAddrs, UdpSocket};
3232

33-
use rand::{thread_rng, Rng};
33+
use rand::{rng, Rng};
3434

3535
pub type Port = u16;
3636

@@ -71,12 +71,12 @@ fn ask_free_tcp_port(ip: IpAddr) -> Option<Port> {
7171
/// let port: u16 = pick_unused_port(IpAddr::V4(Ipv4Addr::LOCALHOST));
7272
/// ```
7373
pub fn pick_unused_port(ip: IpAddr) -> Port {
74-
let mut rng = thread_rng();
74+
let mut rng = rng();
7575

7676
loop {
7777
// Try random port first
7878
for _ in 0..10 {
79-
let port = rng.gen_range(15000..25000);
79+
let port = rng.random_range(15000..25000);
8080
if is_free(ip, port) {
8181
return port;
8282
}

lib/vector-buffers/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ metrics-tracing-context.workspace = true
4242
metrics-util = { workspace = true, features = ["debugging"] }
4343
proptest = "1.6"
4444
quickcheck = "1.0"
45-
rand = "0.8.5"
45+
rand.workspace = true
4646
serde_yaml = { version = "0.9", default-features = false }
4747
temp-dir = "0.1.14"
4848
tokio-test = "0.4.4"

lib/vector-buffers/examples/buffer_perf.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -231,11 +231,11 @@ impl Configuration {
231231
}
232232

233233
fn generate_record_cache(min: usize, max: usize) -> Vec<VariableMessage> {
234-
let mut rng = rand::thread_rng();
234+
let mut rng = rand::rng();
235235
let mut records = Vec::new();
236236
for i in 1..=200_000 {
237-
let payload_size = rng.gen_range(min..max);
238-
let payload = (0..payload_size).map(|_| rng.gen::<u8>()).collect();
237+
let payload_size = rng.random_range(min..max);
238+
let payload = (0..payload_size).map(|_| rng.random::<u8>()).collect();
239239
let message = VariableMessage::new(i, payload);
240240
records.push(message);
241241
}

lib/vector-core/Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,8 @@ toml.workspace = true
8989
ndarray = "0.16.1"
9090
ndarray-stats = "0.6.0"
9191
noisy_float = "0.2.0"
92-
rand = "0.8.5"
93-
rand_distr = "0.4.3"
92+
rand.workspace = true
93+
rand_distr.workspace = true
9494
serde_yaml = { version = "0.9.34", default-features = false }
9595
tracing-subscriber = { version = "0.3.19", default-features = false, features = ["env-filter", "fmt", "ansi", "registry"] }
9696
vector-common = { path = "../vector-common", default-features = false, features = ["test"] }

lib/vector-core/src/metrics/ddsketch.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1106,7 +1106,7 @@ mod tests {
11061106
#[cfg(ddsketch_extended)]
11071107
fn generate_pareto_distribution() -> Vec<OrderedFloat<f64>> {
11081108
use ordered_float::OrderedFloat;
1109-
use rand::thread_rng;
1109+
use rand::rng;
11101110
use rand_distr::{Distribution, Pareto};
11111111

11121112
// Generate a set of samples that roughly correspond to the latency of a typical web
@@ -1116,7 +1116,7 @@ mod tests {
11161116
//let distribution = Gamma::new(1.2, 100.0).unwrap();
11171117
let distribution = Pareto::new(1.0, 1.0).expect("pareto distribution should be valid");
11181118
let mut samples = distribution
1119-
.sample_iter(thread_rng())
1119+
.sample_iter(rng())
11201120
// Scale by 10,000 to get microseconds.
11211121
.map(|n| n * 10_000.0)
11221122
.filter(|n| *n > 15_000.0 && *n < 10_000_000.0)

lib/vector-stream/Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,5 @@ vector-core = { path = "../vector-core" }
2020

2121
[dev-dependencies]
2222
proptest = "1.6"
23-
rand = "0.8.5"
24-
rand_distr = "0.4.3"
23+
rand.workspace = true
24+
rand_distr.workspace = true

lib/vector-stream/src/driver.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -360,9 +360,8 @@ mod tests {
360360
pub(crate) fn get_sleep_dur(&mut self) -> Duration {
361361
let lower = self.lower_bound_us;
362362
let upper = self.upper_bound_us;
363-
364-
// Generate a value between 10ms and 500ms, with a long tail shape to the distribution.
365-
#[allow(clippy::cast_sign_loss)] // Value will be positive anyways
363+
// Generate a value between `lower` and `upper`, with a long tail shape to the distribution.
364+
#[allow(clippy::cast_sign_loss)] // Value will be positive anyway
366365
self.jitter
367366
.sample_iter(&mut self.jitter_gen)
368367
.map(|n| n * lower as f64)

src/api/schema/events/mod.rs

+7-2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ use encoding::EventEncodingType;
99
use futures::{stream, Stream, StreamExt};
1010
use output::{from_tap_payload_to_output_events, OutputEventsPayload};
1111
use rand::{rngs::SmallRng, Rng, SeedableRng};
12+
use std::time::{SystemTime, UNIX_EPOCH};
1213
use tokio::{select, sync::mpsc, time};
1314
use tokio_stream::wrappers::ReceiverStream;
1415
use vector_lib::tap::{
@@ -81,7 +82,11 @@ pub(crate) fn create_events_stream(
8182

8283
// Random number generator to allow for sampling. Speed trumps cryptographic security here.
8384
// The RNG must be Send + Sync to use with the `select!` loop below, hence `SmallRng`.
84-
let mut rng = SmallRng::from_entropy();
85+
let seed = SystemTime::now()
86+
.duration_since(UNIX_EPOCH)
87+
.unwrap()
88+
.as_nanos() as u64;
89+
let mut rng = SmallRng::seed_from_u64(seed);
8590

8691
// Keep a count of the batch size, which will be used as a seed for random eviction
8792
// per the sampling strategy used below.
@@ -113,7 +118,7 @@ pub(crate) fn create_events_stream(
113118
if limit > results.len() {
114119
results.push(payload);
115120
} else {
116-
let random_number = rng.gen_range(0..batch);
121+
let random_number = rng.random_range(0..batch);
117122
if random_number < results.len() {
118123
results[random_number] = payload;
119124
}

src/http.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -462,8 +462,8 @@ impl MaxConnectionAgeLayer {
462462
// Ensure the jitter_factor is between 0.0 and 1.0
463463
let jitter_factor = jitter_factor.clamp(0.0, 1.0);
464464
// Generate a random jitter factor between `1 - jitter_factor`` and `1 + jitter_factor`.
465-
let mut rng = rand::thread_rng();
466-
let random_jitter_factor = rng.gen_range(-jitter_factor..=jitter_factor) + 1.;
465+
let mut rng = rand::rng();
466+
let random_jitter_factor = rng.random_range(-jitter_factor..=jitter_factor) + 1.;
467467
duration.mul_f64(random_jitter_factor)
468468
}
469469
}

src/sinks/aws_cloudwatch_metrics/integration_tests.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ async fn cloudwatch_metrics_namespace_partitioning() {
115115
}
116116
}
117117

118-
events.shuffle(&mut rand::thread_rng());
118+
events.shuffle(&mut rand::rng());
119119

120120
run_and_assert_sink_compliance(sink, stream::iter(events), &AWS_SINK_TAGS).await;
121121
}

src/sinks/databend/service.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use chrono::Utc;
77
use databend_client::error::Error as DatabendError;
88
use databend_client::APIClient as DatabendAPIClient;
99
use futures::future::BoxFuture;
10-
use rand::{thread_rng, Rng};
10+
use rand::{rng, Rng};
1111
use rand_distr::Alphanumeric;
1212
use snafu::Snafu;
1313
use tower::Service;
@@ -117,7 +117,7 @@ impl DatabendService {
117117
.current_database()
118118
.await
119119
.unwrap_or("default".to_string());
120-
let suffix = thread_rng()
120+
let suffix = rng()
121121
.sample_iter(&Alphanumeric)
122122
.take(8)
123123
.map(char::from)

0 commit comments

Comments
 (0)