Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
52 changes: 33 additions & 19 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ vector-lib = { path = "lib/vector-lib", default-features = false, features = ["v
vector-config = { path = "lib/vector-config" }
vector-config-common = { path = "lib/vector-config-common" }
vector-config-macros = { path = "lib/vector-config-macros" }
vrl = { features = ["arbitrary", "cli", "test", "test_framework"], version = "0.24.0" }
vrl = { git = "https://github.com/vectordotdev/vrl.git", branch = "main", features = ["arbitrary", "cli", "test", "test_framework"] }

[dependencies]
cfg-if.workspace = true
Expand Down
4 changes: 2 additions & 2 deletions LICENSE-3rdparty.csv
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ graphql_client_codegen,https://github.com/graphql-rust/graphql-client,Apache-2.0
graphql_query_derive,https://github.com/graphql-rust/graphql-client,Apache-2.0 OR MIT,Tom Houlé <tom@tomhoule.com>
greptime-proto,https://github.com/GreptimeTeam/greptime-proto,Apache-2.0,The greptime-proto Authors
greptimedb-ingester,https://github.com/GreptimeTeam/greptimedb-ingester-rust,Apache-2.0,The greptimedb-ingester Authors
grok,https://github.com/daschl/grok,Apache-2.0,Michael Nitschinger <michael@nitschinger.at>
grok,https://github.com/mmastrac/grok,Apache-2.0,"Matt Mastracci <matthew@mastracci.com>, Michael Nitschinger <michael@nitschinger.at>"
group,https://github.com/zkcrypto/group,MIT OR Apache-2.0,"Sean Bowe <ewillbefull@gmail.com>, Jack Grigg <jack@z.cash>"
h2,https://github.com/hyperium/h2,MIT,"Carl Lerche <me@carllerche.com>, Sean McArthur <sean@seanmonstar.com>"
half,https://github.com/starkat99/half-rs,MIT OR Apache-2.0,Kathryn Long <squeeself@gmail.com>
Expand Down Expand Up @@ -434,7 +434,7 @@ object,https://github.com/gimli-rs/object,Apache-2.0 OR MIT,The object Authors
octseq,https://github.com/NLnetLabs/octets/,BSD-3-Clause,NLnet Labs <rust-team@nlnetlabs.nl>
ofb,https://github.com/RustCrypto/block-modes,MIT OR Apache-2.0,RustCrypto Developers
once_cell,https://github.com/matklad/once_cell,MIT OR Apache-2.0,Aleksey Kladov <aleksey.kladov@gmail.com>
onig,http://github.com/iwillspeak/rust-onig,MIT,"Will Speak <will@willspeak.me>, Ivan Ivashchenko <defuz@me.com>"
onig,https://github.com/iwillspeak/rust-onig,MIT,"Will Speak <will@willspeak.me>, Ivan Ivashchenko <defuz@me.com>"
opaque-debug,https://github.com/RustCrypto/utils,MIT OR Apache-2.0,RustCrypto Developers
opendal,https://github.com/apache/opendal,Apache-2.0,Apache OpenDAL <dev@opendal.apache.org>
openidconnect,https://github.com/ramosbugs/openidconnect-rs,MIT,David A. Ramos <ramos@cs.stanford.edu>
Expand Down
83 changes: 37 additions & 46 deletions lib/vector-core/src/event/vrl_target.rs
Original file line number Diff line number Diff line change
Expand Up @@ -284,10 +284,7 @@ impl Target for VrlTarget {
return Err(MetricPathError::SetPathError.to_string());
}

if let Some(paths) = path
.to_alternative_components(MAX_METRIC_PATH_DEPTH)
.first()
{
if let Some(paths) = path.to_alternative_components(MAX_METRIC_PATH_DEPTH) {
match paths.as_slice() {
["tags"] => {
let value =
Expand Down Expand Up @@ -418,7 +415,6 @@ impl Target for VrlTarget {
if let Some(paths) = target_path
.path
.to_alternative_components(MAX_METRIC_PATH_DEPTH)
.first()
{
let removed_value = match paths.as_slice() {
["namespace"] => metric.series.name.namespace.take().map(Into::into),
Expand Down Expand Up @@ -447,10 +443,10 @@ impl Target for VrlTarget {

value.remove(&target_path.path, false);

return Ok(removed_value);
Ok(removed_value)
} else {
Ok(None)
}

Ok(None)
}
},
PathPrefix::Metadata => Ok(self
Expand Down Expand Up @@ -497,27 +493,25 @@ fn target_get_metric<'a>(

let value = value.get(path);

for paths in path.to_alternative_components(MAX_METRIC_PATH_DEPTH) {
match paths.as_slice() {
["name"] | ["kind"] | ["type"] | ["tags", _] => return Ok(value),
["namespace"] | ["timestamp"] | ["interval_ms"] | ["tags"] => {
if let Some(value) = value {
return Ok(Some(value));
}
}
_ => {
return Err(MetricPathError::InvalidPath {
path: &path.to_string(),
expected: VALID_METRIC_PATHS_GET,
}
.to_string())
}
let Some(paths) = path.to_alternative_components(MAX_METRIC_PATH_DEPTH) else {
return Ok(None);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Before it'd return vec![] on the effective None case and therefore the for loop would never run and would eventually return Ok(None);. This just makes it more explicit + the comment was very misleading

};

match paths.as_slice() {
["name"]
| ["kind"]
| ["type"]
| ["tags", _]
| ["namespace"]
| ["timestamp"]
| ["interval_ms"]
| ["tags"] => Ok(value),
_ => Err(MetricPathError::InvalidPath {
path: &path.to_string(),
expected: VALID_METRIC_PATHS_GET,
}
.to_string()),
}

// We only reach this point if we have requested a tag that doesn't exist or an empty
// field.
Ok(None)
}

fn target_get_mut_metric<'a>(
Expand All @@ -530,27 +524,24 @@ fn target_get_mut_metric<'a>(

let value = value.get_mut(path);

for paths in path.to_alternative_components(MAX_METRIC_PATH_DEPTH) {
match paths.as_slice() {
["name"] | ["kind"] | ["tags", _] => return Ok(value),
["namespace"] | ["timestamp"] | ["tags"] => {
if let Some(value) = value {
return Ok(Some(value));
}
}
_ => {
return Err(MetricPathError::InvalidPath {
path: &path.to_string(),
expected: VALID_METRIC_PATHS_SET,
}
.to_string())
}
let Some(paths) = path.to_alternative_components(MAX_METRIC_PATH_DEPTH) else {
return Ok(None);
};

match paths.as_slice() {
["name"]
| ["kind"]
| ["tags", _]
| ["namespace"]
| ["timestamp"]
| ["interval_ms"]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was missing, feature was working without this so not sure how critical it is

| ["tags"] => Ok(value),
_ => Err(MetricPathError::InvalidPath {
path: &path.to_string(),
expected: VALID_METRIC_PATHS_SET,
}
.to_string()),
}

// We only reach this point if we have requested a tag that doesn't exist or an empty
// field.
Ok(None)
}

/// pre-compute the `Value` structure of the metric.
Expand Down
Loading