From 52b9e7b2b957c290c1c2529d8a48c5e5ec864b77 Mon Sep 17 00:00:00 2001 From: Pavlos Rontidis Date: Mon, 2 Oct 2023 11:27:33 -0400 Subject: [PATCH 1/5] remove 'test' and 'test_framework' VRL features --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1f5bfb12895ae..005c3c0e0a171 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2296,7 +2296,7 @@ dependencies = [ "futures-core", "prost 0.12.1", "prost-types 0.12.1", - "tonic 0.10.1", + "tonic 0.10.2", "tracing-core 0.1.30", ] @@ -2318,7 +2318,7 @@ dependencies = [ "thread_local", "tokio", "tokio-stream", - "tonic 0.10.1", + "tonic 0.10.2", "tracing 0.1.37", "tracing-core 0.1.30", "tracing-subscriber", diff --git a/Cargo.toml b/Cargo.toml index feae5782770f8..5aca99560451e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -118,7 +118,7 @@ members = [ ] [workspace.dependencies] -vrl = { version = "0.7.0", default-features = false, features = ["cli", "test", "test_framework", "arbitrary", "compiler", "value", "diagnostic", "path", "parser", "stdlib", "datadog", "core"] } +vrl = { version = "0.7.0", default-features = false, features = ["cli", "arbitrary", "compiler", "value", "diagnostic", "path", "parser", "stdlib", "datadog", "core"] } pin-project = { version = "1.1.3", default-features = false } From 7d608e19012b5c29e22306d8a92441b9ccc9f11f Mon Sep 17 00:00:00 2001 From: Pavlos Rontidis Date: Mon, 2 Oct 2023 11:33:38 -0400 Subject: [PATCH 2/5] re-enable default features --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 5aca99560451e..5639e0e45a1b6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -118,7 +118,7 @@ members = [ ] [workspace.dependencies] -vrl = { version = "0.7.0", default-features = false, features = ["cli", "arbitrary", "compiler", "value", "diagnostic", "path", "parser", "stdlib", "datadog", "core"] } +vrl = { version = "0.7.0", features = ["cli"] } pin-project = { version = "1.1.3", default-features = false } From c3b4de25bf0a3d8313a94295e172d73a7c87408c Mon Sep 17 00:00:00 2001 From: Pavlos Rontidis Date: Wed, 4 Oct 2023 11:06:18 -0400 Subject: [PATCH 3/5] some NotNan wrappers --- src/enrichment_tables/geoip.rs | 17 +++++++++++++---- src/sources/datadog_agent/traces.rs | 15 +++++++++++---- 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/src/enrichment_tables/geoip.rs b/src/enrichment_tables/geoip.rs index 3a46bf17d8fac..4bc58ab7404c2 100644 --- a/src/enrichment_tables/geoip.rs +++ b/src/enrichment_tables/geoip.rs @@ -6,14 +6,16 @@ //! [geolite]: https://dev.maxmind.com/geoip/geoip2/geolite2/#Download_Access use std::{collections::BTreeMap, fs, net::IpAddr, sync::Arc, time::SystemTime}; -use enrichment::{Case, Condition, IndexHandle, Table}; use maxminddb::{ geoip2::{City, ConnectionType, Isp}, MaxMindDBError, Reader, }; -use vector_config::configurable_component; +use ordered_float::NotNan; use vrl::value::Value; +use enrichment::{Case, Condition, IndexHandle, Table}; +use vector_config::configurable_component; + use crate::config::{EnrichmentTableConfig, GenerateConfig}; // MaxMind GeoIP database files have a type field we can use to recognize specific @@ -180,10 +182,17 @@ impl Geoip { let location = data.location.as_ref(); add_field!("timezone", location.and_then(|location| location.time_zone)); - add_field!("latitude", location.and_then(|location| location.latitude)); + add_field!( + "latitude", + location + .and_then(|location| location.latitude) + .map(|latitude| Value::Float(NotNan::new(latitude).unwrap())) + ); add_field!( "longitude", - location.and_then(|location| location.longitude) + location + .and_then(|location| location.longitude) + .map(|longitude| NotNan::new(longitude).unwrap()) ); add_field!( "metro_code", diff --git a/src/sources/datadog_agent/traces.rs b/src/sources/datadog_agent/traces.rs index bd9099c13a2ab..3fcd37a8d4d96 100644 --- a/src/sources/datadog_agent/traces.rs +++ b/src/sources/datadog_agent/traces.rs @@ -6,11 +6,12 @@ use futures::future; use http::StatusCode; use ordered_float::NotNan; use prost::Message; -use vector_common::internal_event::{CountByteSize, InternalEventHandle as _}; -use vector_core::EstimatedJsonEncodedSizeOf; use vrl::event_path; use warp::{filters::BoxedFilter, path, path::FullPath, reply::Response, Filter, Rejection, Reply}; +use vector_common::internal_event::{CountByteSize, InternalEventHandle as _}; +use vector_core::EstimatedJsonEncodedSizeOf; + use crate::{ event::{Event, TraceEvent, Value}, sources::{ @@ -150,8 +151,14 @@ fn handle_dd_trace_payload_v1( trace_event.insert(&source.log_schema_host_key, hostname.clone()); trace_event.insert(event_path!("env"), env.clone()); trace_event.insert(event_path!("agent_version"), agent_version.clone()); - trace_event.insert(event_path!("target_tps"), target_tps); - trace_event.insert(event_path!("error_tps"), error_tps); + trace_event.insert( + event_path!("target_tps"), + Value::Float(NotNan::new(target_tps).unwrap()), + ); + trace_event.insert( + event_path!("error_tps"), + Value::Float(NotNan::new(error_tps).unwrap()), + ); if let Some(Value::Object(span_tags)) = trace_event.get_mut(event_path!("tags")) { span_tags.extend(tags.clone()); } else { From 404eea7257fc72881a8340e6be4173d7f0becc2c Mon Sep 17 00:00:00 2001 From: Pavlos Rontidis Date: Wed, 4 Oct 2023 11:46:38 -0400 Subject: [PATCH 4/5] replace unwraps with except --- src/enrichment_tables/geoip.rs | 6 ++++-- src/sources/datadog_agent/traces.rs | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/enrichment_tables/geoip.rs b/src/enrichment_tables/geoip.rs index 4bc58ab7404c2..c9289c2c2198e 100644 --- a/src/enrichment_tables/geoip.rs +++ b/src/enrichment_tables/geoip.rs @@ -186,13 +186,15 @@ impl Geoip { "latitude", location .and_then(|location| location.latitude) - .map(|latitude| Value::Float(NotNan::new(latitude).unwrap())) + .map(|latitude| Value::Float( + NotNan::new(latitude).expect("latitude cannot be Nan") + )) ); add_field!( "longitude", location .and_then(|location| location.longitude) - .map(|longitude| NotNan::new(longitude).unwrap()) + .map(|longitude| NotNan::new(longitude).expect("longitude cannot be Nan")) ); add_field!( "metro_code", diff --git a/src/sources/datadog_agent/traces.rs b/src/sources/datadog_agent/traces.rs index 3fcd37a8d4d96..c5daa9a4b2910 100644 --- a/src/sources/datadog_agent/traces.rs +++ b/src/sources/datadog_agent/traces.rs @@ -153,11 +153,11 @@ fn handle_dd_trace_payload_v1( trace_event.insert(event_path!("agent_version"), agent_version.clone()); trace_event.insert( event_path!("target_tps"), - Value::Float(NotNan::new(target_tps).unwrap()), + Value::Float(NotNan::new(target_tps).expect("target_tps cannot be Nan")), ); trace_event.insert( event_path!("error_tps"), - Value::Float(NotNan::new(error_tps).unwrap()), + Value::Float(NotNan::new(error_tps).expect("error_tps cannot be Nan")), ); if let Some(Value::Object(span_tags)) = trace_event.get_mut(event_path!("tags")) { span_tags.extend(tags.clone()); From e9abda65f22aeeb5d9f0f158d302d3b5a03430ff Mon Sep 17 00:00:00 2001 From: Pavlos Rontidis Date: Wed, 4 Oct 2023 13:22:22 -0400 Subject: [PATCH 5/5] vector-vrl requires test and test_framework --- lib/vector-vrl/tests/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/vector-vrl/tests/Cargo.toml b/lib/vector-vrl/tests/Cargo.toml index 672a60522618c..73e6d9e5df72f 100644 --- a/lib/vector-vrl/tests/Cargo.toml +++ b/lib/vector-vrl/tests/Cargo.toml @@ -7,7 +7,7 @@ publish = false [dependencies] enrichment = { path = "../../enrichment" } -vrl.workspace = true +vrl = { version = "0.7.0", features = ["test", "test_framework"] } vector-vrl-functions = { path = "../../vector-vrl/functions" } ansi_term = "0.12"