Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 19 additions & 19 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions changelog.d/vrl-query-performance.enhancement.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Improve VRL performance when reading variable subpaths and event or metadata fields.

authors: gwenaskell
4 changes: 2 additions & 2 deletions lib/codecs/src/decoding/format/protobuf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ mod tests {
assert_eq!(log["name"], "someone".into());
assert_eq!(
log["phones"].as_array().unwrap()[0].as_object().unwrap()["number"]
.as_str()
.to_str_lossy()
.unwrap(),
"123456"
);
Expand All @@ -278,7 +278,7 @@ mod tests {
assert_eq!(log["name"], "someone".into());
assert_eq!(
log["phones"].as_array().unwrap()[0].as_object().unwrap()["number"]
.as_str()
.to_str_lossy()
.unwrap(),
"1234"
);
Expand Down
2 changes: 1 addition & 1 deletion lib/vector-vrl/functions/src/get_secret.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use vrl::prelude::*;
reason = "Keep the fallible return convention used by VRL runtime helpers."
)]
fn get_secret(ctx: &mut Context, key: Value) -> std::result::Result<Value, ExpressionError> {
let key_str = key.as_str().expect("argument must be a string");
let key_str = key.to_str_lossy().expect("argument must be a string");
let value = match ctx.target().get_secret(key_str.as_ref()) {
Some(secret) => secret.into(),
None => Value::Null,
Expand Down
2 changes: 1 addition & 1 deletion lib/vector-vrl/functions/src/remove_secret.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use vrl::prelude::*;
reason = "Keep the fallible return convention used by VRL runtime helpers."
)]
fn remove_secret(ctx: &mut Context, key: Value) -> std::result::Result<Value, ExpressionError> {
let key_str = key.as_str().expect("argument must be a string");
let key_str = key.to_str_lossy().expect("argument must be a string");
ctx.target_mut().remove_secret(key_str.as_ref());
Ok(Value::Null)
}
Expand Down
4 changes: 2 additions & 2 deletions lib/vector-vrl/functions/src/set_secret.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ fn set_secret(
key: Value,
secret: Value,
) -> std::result::Result<Value, ExpressionError> {
let key_str = key.as_str().expect("key must be a string");
let secret_str = secret.as_str().expect("secret must be a string");
let key_str = key.to_str_lossy().expect("key must be a string");
let secret_str = secret.to_str_lossy().expect("secret must be a string");

ctx.target_mut()
.insert_secret(key_str.as_ref(), secret_str.as_ref());
Expand Down
2 changes: 1 addition & 1 deletion lib/vector-vrl/functions/src/set_semantic_meaning.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ impl Function for SetSemanticMeaning {
.expect("meaning not bytes")
.into_owned();

let Some(path) = query.external_path() else {
let Some(path) = query.external_path().cloned() else {
// Semantic meaning can only be assigned to external fields.
let mut labels = vec![Label::primary(
"this path must point to an event or metadata",
Expand Down
2 changes: 1 addition & 1 deletion lib/vector-vrl/metrics/src/aggregate_vector_metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ fn aggregate_metrics(
key: Value,
tags: BTreeMap<String, String>,
) -> Result<Value, ExpressionError> {
let key_str = key.as_str().expect("argument must be a string");
let key_str = key.to_str_lossy().expect("argument must be a string");
let metrics = metrics_storage.find_metrics(&key_str, tags);

let metric_values = metrics.into_iter().filter_map(|m| match m.value() {
Expand Down
6 changes: 3 additions & 3 deletions lib/vector-vrl/metrics/src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ pub(crate) fn resolve_tags(
v.resolve(ctx).and_then(|v| {
Ok((
k.clone().into(),
v.as_str().ok_or("Tag must be a string")?.into_owned(),
v.to_str_lossy().ok_or("Tag must be a string")?.into_owned(),
))
})
})
Expand Down Expand Up @@ -267,7 +267,7 @@ mod tests {
value: f64,
tags: Option<Vec<(&str, &str)>>,
) {
assert_eq!(metric.get("name").unwrap().as_str().unwrap(), name);
assert_eq!(metric.get("name").unwrap().to_str_lossy().unwrap(), name);
assert_eq!(
metric.get("value").unwrap().as_float().unwrap(),
NotNan::new(value).unwrap()
Expand All @@ -283,7 +283,7 @@ mod tests {
.as_array_unwrap()
.first()
.unwrap()
.as_str()
.to_str_lossy()
.unwrap(),
value
);
Expand Down
2 changes: 1 addition & 1 deletion lib/vector-vrl/metrics/src/find_vector_metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ fn find_metrics(
key: Value,
tags: BTreeMap<String, String>,
) -> Result<Value, ExpressionError> {
let key_str = key.as_str().expect("argument must be a string");
let key_str = key.to_str_lossy().expect("argument must be a string");
Ok(Value::Array(
metrics_storage
.find_metrics(&key_str, tags)
Expand Down
2 changes: 1 addition & 1 deletion lib/vector-vrl/metrics/src/get_vector_metric.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ fn get_metric(
key: Value,
tags: BTreeMap<String, String>,
) -> Result<Value, ExpressionError> {
let key_str = key.as_str().expect("argument must be a string");
let key_str = key.to_str_lossy().expect("argument must be a string");
let value = match metrics_storage.get_metric(&key_str, tags) {
Some(value) => metric_into_vrl(&value),
None => Value::Null,
Expand Down
Loading