Skip to content

Commit

Permalink
chore(deps): clean up VRL crate features (vectordotdev#18740)
Browse files Browse the repository at this point in the history
* remove 'test' and 'test_framework' VRL features

* re-enable default features

* some NotNan wrappers

* replace unwraps with except

* vector-vrl requires test and test_framework
  • Loading branch information
pront authored Oct 4, 2023
1 parent 2b15c63 commit 1452d54
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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", features = ["cli"] }

pin-project = { version = "1.1.3", default-features = false }

Expand Down
2 changes: 1 addition & 1 deletion lib/vector-vrl/tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
19 changes: 15 additions & 4 deletions src/enrichment_tables/geoip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -180,10 +182,19 @@ 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).expect("latitude cannot be Nan")
))
);
add_field!(
"longitude",
location.and_then(|location| location.longitude)
location
.and_then(|location| location.longitude)
.map(|longitude| NotNan::new(longitude).expect("longitude cannot be Nan"))
);
add_field!(
"metro_code",
Expand Down
15 changes: 11 additions & 4 deletions src/sources/datadog_agent/traces.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{
Expand Down Expand Up @@ -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).expect("target_tps cannot be Nan")),
);
trace_event.insert(
event_path!("error_tps"),
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());
} else {
Expand Down

0 comments on commit 1452d54

Please sign in to comment.