From 2439b62d2597be84e02fe78d4095741cdc144980 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 29 Sep 2023 11:50:42 -0400 Subject: [PATCH] chore(deps): Bump chrono from 0.4.30 to 0.4.31 (#18583) * chore(deps): Bump chrono from 0.4.30 to 0.4.31 Bumps [chrono](https://github.com/chronotope/chrono) from 0.4.30 to 0.4.31. - [Release notes](https://github.com/chronotope/chrono/releases) - [Changelog](https://github.com/chronotope/chrono/blob/main/CHANGELOG.md) - [Commits](https://github.com/chronotope/chrono/compare/v0.4.30...v0.4.31) --- updated-dependencies: - dependency-name: chrono dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] * Expand deprecated function `DateTime::timestamp_nanos` This function internally just calls `.timestamp_nanos_opt().expect()` * Change message on expect --------- Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Bruce Guenter --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- lib/enrichment/Cargo.toml | 2 +- lib/fakedata/Cargo.toml | 2 +- lib/loki-logproto/src/lib.rs | 10 ++++++++-- lib/opentelemetry-proto/Cargo.toml | 2 +- lib/vector-api-client/Cargo.toml | 2 +- lib/vector-config/Cargo.toml | 2 +- lib/vector-core/Cargo.toml | 2 +- .../datadog/traces/apm_stats/aggregation.rs | 18 ++++++++++++++---- .../traces/apm_stats/integration_tests.rs | 4 +++- src/sinks/datadog/traces/request_builder.rs | 4 +++- src/sinks/influxdb/logs.rs | 5 ++++- src/sinks/influxdb/metrics.rs | 7 ++++++- src/sinks/influxdb/mod.rs | 8 +++++--- src/sinks/loki/integration_tests.rs | 14 ++++++++++++-- src/sinks/loki/sink.rs | 6 ++++-- src/sources/datadog_agent/integration_tests.rs | 4 +++- src/sources/splunk_hec/mod.rs | 9 ++++++--- vdev/Cargo.toml | 2 +- 20 files changed, 78 insertions(+), 31 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 8f512768501543..d35cf03c48ffc8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1959,9 +1959,9 @@ dependencies = [ [[package]] name = "chrono" -version = "0.4.30" +version = "0.4.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "defd4e7873dbddba6c7c91e199c7fcb946abc4a6a4ac3195400bcfb01b5de877" +checksum = "7f2c685bad3eb3d45a01354cedb7d5faa66194d1d58ba6e267a8de788f79db38" dependencies = [ "android-tzdata", "iana-time-zone", diff --git a/Cargo.toml b/Cargo.toml index 75555ad2cbcc3f..5b44a61a3cbb92 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -252,7 +252,7 @@ bloomy = { version = "1.2.0", default-features = false, optional = true } bollard = { version = "0.15.0", default-features = false, features = ["ssl", "chrono"], optional = true } bytes = { version = "1.5.0", default-features = false, features = ["serde"] } bytesize = { version = "1.3.0", default-features = false } -chrono = { version = "0.4.30", default-features = false, features = ["serde"] } +chrono = { version = "0.4.31", default-features = false, features = ["serde"] } cidr-utils = { version = "0.5.11", default-features = false } clap = { version = "4.4.3", default-features = false, features = ["derive", "error-context", "env", "help", "std", "string", "usage", "wrap_help"] } colored = { version = "2.0.4", default-features = false } diff --git a/lib/enrichment/Cargo.toml b/lib/enrichment/Cargo.toml index 901bf6d0b45fba..45de147609dbf4 100644 --- a/lib/enrichment/Cargo.toml +++ b/lib/enrichment/Cargo.toml @@ -7,6 +7,6 @@ publish = false [dependencies] arc-swap = { version = "1.6.0", default-features = false } -chrono = { version = "0.4.19", default-features = false } +chrono = { version = "0.4.31", default-features = false } dyn-clone = { version = "1.0.14", default-features = false } vrl.workspace = true diff --git a/lib/fakedata/Cargo.toml b/lib/fakedata/Cargo.toml index d4c27a51a8a7ee..6dedcb99df25e4 100644 --- a/lib/fakedata/Cargo.toml +++ b/lib/fakedata/Cargo.toml @@ -7,6 +7,6 @@ publish = false license = "MPL-2.0" [dependencies] -chrono = "0.4.19" +chrono = "0.4.31" fakedata_generator = "0.2.4" rand = "0.8.5" diff --git a/lib/loki-logproto/src/lib.rs b/lib/loki-logproto/src/lib.rs index 44ab526d8f8eac..ec7fee42c7613a 100644 --- a/lib/loki-logproto/src/lib.rs +++ b/lib/loki-logproto/src/lib.rs @@ -103,12 +103,18 @@ mod tests { .timestamp_opt(1640244790, 0) .single() .expect("invalid timestamp"); - let entry1 = Entry(ts1.timestamp_nanos(), "hello".into()); + let entry1 = Entry( + ts1.timestamp_nanos_opt().expect("Timestamp out of range"), + "hello".into(), + ); let ts2 = Utc .timestamp_opt(1640244791, 0) .single() .expect("invalid timestamp"); - let entry2 = Entry(ts2.timestamp_nanos(), "world".into()); + let entry2 = Entry( + ts2.timestamp_nanos_opt().expect("Timestamp out of range"), + "world".into(), + ); let labels = vec![("source".into(), "protobuf-test".into())] .into_iter() .collect(); diff --git a/lib/opentelemetry-proto/Cargo.toml b/lib/opentelemetry-proto/Cargo.toml index 66a0f377bf6e3e..2dc2f93d207cb5 100644 --- a/lib/opentelemetry-proto/Cargo.toml +++ b/lib/opentelemetry-proto/Cargo.toml @@ -11,7 +11,7 @@ tonic-build = { version = "0.10", default-features = false, features = ["prost", [dependencies] bytes = { version = "1.5.0", default-features = false, features = ["serde"] } -chrono = { version = "0.4.19", default-features = false, features = ["serde"] } +chrono = { version = "0.4.31", default-features = false, features = ["serde"] } hex = { version = "0.4.3", default-features = false, features = ["std"] } lookup = { package = "vector-lookup", path = "../vector-lookup", default-features = false } ordered-float = { version = "4.1.0", default-features = false } diff --git a/lib/vector-api-client/Cargo.toml b/lib/vector-api-client/Cargo.toml index bd1f8392eb34ec..1591f6eb67250a 100644 --- a/lib/vector-api-client/Cargo.toml +++ b/lib/vector-api-client/Cargo.toml @@ -29,7 +29,7 @@ reqwest = { version = "0.11.20", default-features = false, features = ["json"] } tokio-tungstenite = { version = "0.20.1", default-features = false, features = ["connect", "rustls"] } # External libs -chrono = { version = "0.4.6", default-features = false, features = ["serde"] } +chrono = { version = "0.4.31", default-features = false, features = ["serde"] } clap = { version = "4.4.3", default-features = false, features = ["derive"] } url = { version = "2.4.1", default-features = false } uuid = { version = "1", default-features = false, features = ["serde", "v4"] } diff --git a/lib/vector-config/Cargo.toml b/lib/vector-config/Cargo.toml index 9aa7dac4e94cd6..99b1bdbdc50cac 100644 --- a/lib/vector-config/Cargo.toml +++ b/lib/vector-config/Cargo.toml @@ -11,7 +11,7 @@ name = "integration" path = "tests/integration/lib.rs" [dependencies] -chrono = { version = "0.4.19", default-features = false } +chrono = { version = "0.4.31", default-features = false } chrono-tz = { version = "0.8.3", default-features = false } encoding_rs = { version = "0.8", default-features = false, features = ["alloc", "serde"] } indexmap = { version = "2.0", default-features = false, features = ["std"] } diff --git a/lib/vector-core/Cargo.toml b/lib/vector-core/Cargo.toml index 0746584417417b..6ed305ded88023 100644 --- a/lib/vector-core/Cargo.toml +++ b/lib/vector-core/Cargo.toml @@ -11,7 +11,7 @@ async-stream = { version = "0.3.5", default-features = false } async-trait = { version = "0.1", default-features = false } bitmask-enum = { version = "2.2.2", default-features = false } bytes = { version = "1.5.0", default-features = false, features = ["serde"] } -chrono = { version = "0.4.19", default-features = false, features = ["serde"] } +chrono = { version = "0.4.31", default-features = false, features = ["serde"] } crossbeam-utils = { version = "0.8.16", default-features = false } db-key = { version = "0.0.5", default-features = false, optional = true } dyn-clone = { version = "1.0.14", default-features = false } diff --git a/src/sinks/datadog/traces/apm_stats/aggregation.rs b/src/sinks/datadog/traces/apm_stats/aggregation.rs index 2c7d3a580e6ad1..7d990b6c803e43 100644 --- a/src/sinks/datadog/traces/apm_stats/aggregation.rs +++ b/src/sinks/datadog/traces/apm_stats/aggregation.rs @@ -124,7 +124,11 @@ impl Aggregator { pub fn new(default_api_key: Arc) -> Self { Self { buckets: BTreeMap::new(), - oldest_timestamp: align_timestamp(Utc::now().timestamp_nanos() as u64), + oldest_timestamp: align_timestamp( + Utc::now() + .timestamp_nanos_opt() + .expect("Timestamp out of range") as u64, + ), default_api_key, // We can't know the below fields until have received a trace event agent_env: None, @@ -228,8 +232,12 @@ impl Aggregator { let aggkey = AggregationKey::new_aggregation_from_span(span, payload_aggkey, synthetics); let start = match span.get("start") { - Some(Value::Timestamp(val)) => val.timestamp_nanos() as u64, - _ => Utc::now().timestamp_nanos() as u64, + Some(Value::Timestamp(val)) => { + val.timestamp_nanos_opt().expect("Timestamp out of range") as u64 + } + _ => Utc::now() + .timestamp_nanos_opt() + .expect("Timestamp out of range") as u64, }; let duration = match span.get("duration") { @@ -277,7 +285,9 @@ impl Aggregator { // Based on https://github.com/DataDog/datadog-agent/blob/cfa750c7412faa98e87a015f8ee670e5828bbe7f/pkg/trace/stats/concentrator.go#L38-L41 // , and https://github.com/DataDog/datadog-agent/blob/cfa750c7412faa98e87a015f8ee670e5828bbe7f/pkg/trace/stats/concentrator.go#L195-L207 - let now = Utc::now().timestamp_nanos() as u64; + let now = Utc::now() + .timestamp_nanos_opt() + .expect("Timestamp out of range") as u64; let flush_cutoff_time = if force { // flush all the remaining buckets (the Vector process is exiting) diff --git a/src/sinks/datadog/traces/apm_stats/integration_tests.rs b/src/sinks/datadog/traces/apm_stats/integration_tests.rs index 4ca0207e30371d..50c49066d9dfa8 100644 --- a/src/sinks/datadog/traces/apm_stats/integration_tests.rs +++ b/src/sinks/datadog/traces/apm_stats/integration_tests.rs @@ -417,7 +417,9 @@ async fn apm_stats_e2e_test_dd_agent_to_vector_correctness() { // the URLs of the Agent trace endpoints that traces will be sent to let urls = vec![trace_agent_only_url(), trace_agent_to_vector_url()]; - let start = Utc::now().timestamp_nanos(); + let start = Utc::now() + .timestamp_nanos_opt() + .expect("Timestamp out of range"); let duration = 1; let span_id = 3; diff --git a/src/sinks/datadog/traces/request_builder.rs b/src/sinks/datadog/traces/request_builder.rs index 64fa9f0d9c7ede..01ec1742a381ee 100644 --- a/src/sinks/datadog/traces/request_builder.rs +++ b/src/sinks/datadog/traces/request_builder.rs @@ -382,7 +382,9 @@ impl DatadogTracesEncoder { _ => 0, }; let start = match span.get("start") { - Some(Value::Timestamp(val)) => val.timestamp_nanos(), + Some(Value::Timestamp(val)) => { + val.timestamp_nanos_opt().expect("Timestamp out of range") + } _ => 0, }; diff --git a/src/sinks/influxdb/logs.rs b/src/sinks/influxdb/logs.rs index 3f4ead23ca46b7..f84b75daef9a67 100644 --- a/src/sinks/influxdb/logs.rs +++ b/src/sinks/influxdb/logs.rs @@ -904,7 +904,10 @@ mod integration_tests { onboarding_v2(&endpoint).await; let now = Utc::now(); - let measure = format!("vector-{}", now.timestamp_nanos()); + let measure = format!( + "vector-{}", + now.timestamp_nanos_opt().expect("Timestamp out of range") + ); let cx = SinkContext::default(); diff --git a/src/sinks/influxdb/metrics.rs b/src/sinks/influxdb/metrics.rs index 68dd5182cadf19..31faab4ffe6446 100644 --- a/src/sinks/influxdb/metrics.rs +++ b/src/sinks/influxdb/metrics.rs @@ -1109,7 +1109,12 @@ mod integration_tests { acknowledgements: Default::default(), }; - let metric = format!("counter-{}", Utc::now().timestamp_nanos()); + let metric = format!( + "counter-{}", + Utc::now() + .timestamp_nanos_opt() + .expect("Timestamp out of range") + ); let mut events = Vec::new(); for i in 0..10 { let event = Event::Metric( diff --git a/src/sinks/influxdb/mod.rs b/src/sinks/influxdb/mod.rs index 4cefce45e39921..a2b322c74ddf88 100644 --- a/src/sinks/influxdb/mod.rs +++ b/src/sinks/influxdb/mod.rs @@ -342,7 +342,7 @@ fn encode_string(key: &str, output: &mut BytesMut) { pub(in crate::sinks) fn encode_timestamp(timestamp: Option>) -> i64 { if let Some(ts) = timestamp { - ts.timestamp_nanos() + ts.timestamp_nanos_opt().unwrap() } else { encode_timestamp(Some(Utc::now())) } @@ -390,7 +390,7 @@ pub mod test_util { pub(crate) const TOKEN: &str = "my-token"; pub(crate) fn next_database() -> String { - format!("testdb{}", Utc::now().timestamp_nanos()) + format!("testdb{}", Utc::now().timestamp_nanos_opt().unwrap()) } pub(crate) fn ts() -> DateTime { @@ -834,7 +834,9 @@ mod tests { #[test] fn test_encode_timestamp() { - let start = Utc::now().timestamp_nanos(); + let start = Utc::now() + .timestamp_nanos_opt() + .expect("Timestamp out of range"); assert_eq!(encode_timestamp(Some(ts())), 1542182950000000011); assert!(encode_timestamp(None) >= start) } diff --git a/src/sinks/loki/integration_tests.rs b/src/sinks/loki/integration_tests.rs index 68ec244e04c98d..f93828b353956b 100644 --- a/src/sinks/loki/integration_tests.rs +++ b/src/sinks/loki/integration_tests.rs @@ -210,7 +210,12 @@ async fn namespaced_timestamp() { // The timestamp of the event needs to be the timestamp set in the `norknork` // field since that was given the meaning of `timestamp`. - assert_eq!(timestamp.timestamp_nanos(), timestamps[i]); + assert_eq!( + timestamp + .timestamp_nanos_opt() + .expect("Timestamp out of range"), + timestamps[i] + ); } } @@ -675,7 +680,12 @@ async fn test_out_of_order_events( ) } for (i, ts) in timestamps.iter().enumerate() { - assert_eq!(get_timestamp(&expected[i]).timestamp_nanos(), *ts); + assert_eq!( + get_timestamp(&expected[i]) + .timestamp_nanos_opt() + .expect("Timestamp out of range"), + *ts + ); } } diff --git a/src/sinks/loki/sink.rs b/src/sinks/loki/sink.rs index 89ae9857ee746c..9d9046788d04bc 100644 --- a/src/sinks/loki/sink.rs +++ b/src/sinks/loki/sink.rs @@ -257,8 +257,10 @@ impl EventEncoder { self.remove_label_fields(&mut event); let timestamp = match event.as_log().get_timestamp() { - Some(Value::Timestamp(ts)) => ts.timestamp_nanos(), - _ => chrono::Utc::now().timestamp_nanos(), + Some(Value::Timestamp(ts)) => ts.timestamp_nanos_opt().expect("Timestamp out of range"), + _ => chrono::Utc::now() + .timestamp_nanos_opt() + .expect("Timestamp out of range"), }; if self.remove_timestamp { diff --git a/src/sources/datadog_agent/integration_tests.rs b/src/sources/datadog_agent/integration_tests.rs index 45794732d9a007..b5b7e9120b9bf6 100644 --- a/src/sources/datadog_agent/integration_tests.rs +++ b/src/sources/datadog_agent/integration_tests.rs @@ -185,6 +185,8 @@ fn get_simple_trace() -> String { ] ] "#}, - Utc::now().timestamp_nanos() + Utc::now() + .timestamp_nanos_opt() + .expect("Timestamp out of range") ) } diff --git a/src/sources/splunk_hec/mod.rs b/src/sources/splunk_hec/mod.rs index 41a15547c9c6f0..ac597caf2be065 100644 --- a/src/sources/splunk_hec/mod.rs +++ b/src/sources/splunk_hec/mod.rs @@ -2123,7 +2123,7 @@ mod tests { for case in cases { let sec = case.timestamp(); let millis = case.timestamp_millis(); - let nano = case.timestamp_nanos(); + let nano = case.timestamp_nanos_opt().expect("Timestamp out of range"); assert_eq!(parse_timestamp(sec).unwrap().timestamp(), case.timestamp()); assert_eq!( @@ -2131,8 +2131,11 @@ mod tests { case.timestamp_millis() ); assert_eq!( - parse_timestamp(nano).unwrap().timestamp_nanos(), - case.timestamp_nanos() + parse_timestamp(nano) + .unwrap() + .timestamp_nanos_opt() + .unwrap(), + case.timestamp_nanos_opt().expect("Timestamp out of range") ); } diff --git a/vdev/Cargo.toml b/vdev/Cargo.toml index 44406dbe7fe3c7..b06c06e97d6b92 100644 --- a/vdev/Cargo.toml +++ b/vdev/Cargo.toml @@ -11,7 +11,7 @@ publish = false anyhow = "1.0.75" atty = "0.2.14" cached = "0.45.1" -chrono = { version = "0.4.22", default-features = false, features = ["serde", "clock"] } +chrono = { version = "0.4.31", default-features = false, features = ["serde", "clock"] } clap = { version = "4.4.3", features = ["derive"] } clap-verbosity-flag = "2.0.1" clap_complete = "4.4.2"